| 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
| 2 | |* *| |
| 3 | |* Parsed attribute helpers *| |
| 4 | |* *| |
| 5 | |* Automatically generated file, do not edit! *| |
| 6 | |* *| |
| 7 | \*===----------------------------------------------------------------------===*/ |
| 8 | |
| 9 | static bool isStruct(const Decl *D) { |
| 10 | if (const auto *S = dyn_cast<RecordDecl>(D)) |
| 11 | return !S->isUnion(); |
| 12 | return false; |
| 13 | } |
| 14 | |
| 15 | static bool isSharedVar(const Decl *D) { |
| 16 | if (const auto *S = dyn_cast<VarDecl>(D)) |
| 17 | return S->hasGlobalStorage() && !S->getTLSKind(); |
| 18 | return false; |
| 19 | } |
| 20 | |
| 21 | static bool isGlobalVar(const Decl *D) { |
| 22 | if (const auto *S = dyn_cast<VarDecl>(D)) |
| 23 | return S->hasGlobalStorage(); |
| 24 | return false; |
| 25 | } |
| 26 | |
| 27 | static bool isHasFunctionProto(const Decl *D) { |
| 28 | if (const auto *S = dyn_cast<Decl>(D)) |
| 29 | return (S->getFunctionType(true) != nullptr && |
| 30 | isa<FunctionProtoType>(S->getFunctionType())) || |
| 31 | isa<ObjCMethodDecl>(S) || |
| 32 | isa<BlockDecl>(S); |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | static bool isFunctionLike(const Decl *D) { |
| 37 | if (const auto *S = dyn_cast<Decl>(D)) |
| 38 | return S->getFunctionType(false) != nullptr; |
| 39 | return false; |
| 40 | } |
| 41 | |
| 42 | static bool isInlineFunction(const Decl *D) { |
| 43 | if (const auto *S = dyn_cast<FunctionDecl>(D)) |
| 44 | return S->isInlineSpecified(); |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | static bool isLocalVar(const Decl *D) { |
| 49 | if (const auto *S = dyn_cast<VarDecl>(D)) |
| 50 | return S->hasLocalStorage() && !isa<ParmVarDecl>(S); |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | static bool isObjCInstanceMethod(const Decl *D) { |
| 55 | if (const auto *S = dyn_cast<ObjCMethodDecl>(D)) |
| 56 | return S->isInstanceMethod(); |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | static bool isImplicitObjectParameter(const Decl *D) { |
| 61 | if (const auto *S = dyn_cast<FunctionDecl>(D)) |
| 62 | return static_cast<void>(S), false; |
| 63 | return false; |
| 64 | } |
| 65 | |
| 66 | static bool isNonParmVar(const Decl *D) { |
| 67 | if (const auto *S = dyn_cast<VarDecl>(D)) |
| 68 | return S->getKind() != Decl::ParmVar; |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | static bool isNonBitField(const Decl *D) { |
| 73 | if (const auto *S = dyn_cast<FieldDecl>(D)) |
| 74 | return !S->isBitField(); |
| 75 | return false; |
| 76 | } |
| 77 | |
| 78 | static bool isNonStaticCXXMethod(const Decl *D) { |
| 79 | if (const auto *S = dyn_cast<CXXMethodDecl>(D)) |
| 80 | return !S->isStatic(); |
| 81 | return false; |
| 82 | } |
| 83 | |
| 84 | static bool isClassTmpl(const Decl *D) { |
| 85 | if (const auto *S = dyn_cast<CXXRecordDecl>(D)) |
| 86 | return S->getDescribedClassTemplate(); |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | static bool isNonStaticNonConstCXXMethod(const Decl *D) { |
| 91 | if (const auto *S = dyn_cast<CXXMethodDecl>(D)) |
| 92 | return !S->isStatic() && !S->isConst(); |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | static bool isFunctionTmpl(const Decl *D) { |
| 97 | if (const auto *S = dyn_cast<FunctionDecl>(D)) |
| 98 | return S->getTemplatedKind() == |
| 99 | FunctionDecl::TK_FunctionTemplate; |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | static bool isTLSVar(const Decl *D) { |
| 104 | if (const auto *S = dyn_cast<VarDecl>(D)) |
| 105 | return S->getTLSKind() != 0; |
| 106 | return false; |
| 107 | } |
| 108 | |
| 109 | static bool isNonLocalVar(const Decl *D) { |
| 110 | if (const auto *S = dyn_cast<VarDecl>(D)) |
| 111 | return !S->hasLocalStorage(); |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | static constexpr ParsedAttrInfo::Spelling AArch64VectorPcsSpellings[] = { |
| 116 | {AttributeCommonInfo::AS_GNU, "aarch64_vector_pcs" }, |
| 117 | {AttributeCommonInfo::AS_CXX11, "clang::aarch64_vector_pcs" }, |
| 118 | {AttributeCommonInfo::AS_C2x, "clang::aarch64_vector_pcs" }, |
| 119 | }; |
| 120 | struct ParsedAttrInfoAArch64VectorPcs final : public ParsedAttrInfo { |
| 121 | ParsedAttrInfoAArch64VectorPcs() { |
| 122 | AttrKind = ParsedAttr::AT_AArch64VectorPcs; |
| 123 | NumArgs = 0; |
| 124 | OptArgs = 0; |
| 125 | HasCustomParsing = 0; |
| 126 | IsTargetSpecific = 0; |
| 127 | IsType = 1; |
| 128 | IsStmt = 0; |
| 129 | IsKnownToGCC = 0; |
| 130 | IsSupportedByPragmaAttribute = 0; |
| 131 | Spellings = AArch64VectorPcsSpellings; |
| 132 | } |
| 133 | static const ParsedAttrInfoAArch64VectorPcs Instance; |
| 134 | }; |
| 135 | const ParsedAttrInfoAArch64VectorPcs ParsedAttrInfoAArch64VectorPcs::Instance; |
| 136 | static constexpr ParsedAttrInfo::Spelling AMDGPUFlatWorkGroupSizeSpellings[] = { |
| 137 | {AttributeCommonInfo::AS_GNU, "amdgpu_flat_work_group_size" }, |
| 138 | {AttributeCommonInfo::AS_CXX11, "clang::amdgpu_flat_work_group_size" }, |
| 139 | }; |
| 140 | struct ParsedAttrInfoAMDGPUFlatWorkGroupSize final : public ParsedAttrInfo { |
| 141 | ParsedAttrInfoAMDGPUFlatWorkGroupSize() { |
| 142 | AttrKind = ParsedAttr::AT_AMDGPUFlatWorkGroupSize; |
| 143 | NumArgs = 2; |
| 144 | OptArgs = 0; |
| 145 | HasCustomParsing = 0; |
| 146 | IsTargetSpecific = 0; |
| 147 | IsType = 0; |
| 148 | IsStmt = 0; |
| 149 | IsKnownToGCC = 0; |
| 150 | IsSupportedByPragmaAttribute = 1; |
| 151 | Spellings = AMDGPUFlatWorkGroupSizeSpellings; |
| 152 | } |
| 153 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 154 | if (!isa<FunctionDecl>(D)) { |
| 155 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 156 | << Attr << "kernel functions" ; |
| 157 | return false; |
| 158 | } |
| 159 | return true; |
| 160 | } |
| 161 | |
| 162 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 163 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 164 | } |
| 165 | |
| 166 | static const ParsedAttrInfoAMDGPUFlatWorkGroupSize Instance; |
| 167 | }; |
| 168 | const ParsedAttrInfoAMDGPUFlatWorkGroupSize ParsedAttrInfoAMDGPUFlatWorkGroupSize::Instance; |
| 169 | static constexpr ParsedAttrInfo::Spelling AMDGPUNumSGPRSpellings[] = { |
| 170 | {AttributeCommonInfo::AS_GNU, "amdgpu_num_sgpr" }, |
| 171 | {AttributeCommonInfo::AS_CXX11, "clang::amdgpu_num_sgpr" }, |
| 172 | }; |
| 173 | struct ParsedAttrInfoAMDGPUNumSGPR final : public ParsedAttrInfo { |
| 174 | ParsedAttrInfoAMDGPUNumSGPR() { |
| 175 | AttrKind = ParsedAttr::AT_AMDGPUNumSGPR; |
| 176 | NumArgs = 1; |
| 177 | OptArgs = 0; |
| 178 | HasCustomParsing = 0; |
| 179 | IsTargetSpecific = 0; |
| 180 | IsType = 0; |
| 181 | IsStmt = 0; |
| 182 | IsKnownToGCC = 0; |
| 183 | IsSupportedByPragmaAttribute = 1; |
| 184 | Spellings = AMDGPUNumSGPRSpellings; |
| 185 | } |
| 186 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 187 | if (!isa<FunctionDecl>(D)) { |
| 188 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 189 | << Attr << "kernel functions" ; |
| 190 | return false; |
| 191 | } |
| 192 | return true; |
| 193 | } |
| 194 | |
| 195 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 196 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 197 | } |
| 198 | |
| 199 | static const ParsedAttrInfoAMDGPUNumSGPR Instance; |
| 200 | }; |
| 201 | const ParsedAttrInfoAMDGPUNumSGPR ParsedAttrInfoAMDGPUNumSGPR::Instance; |
| 202 | static constexpr ParsedAttrInfo::Spelling AMDGPUNumVGPRSpellings[] = { |
| 203 | {AttributeCommonInfo::AS_GNU, "amdgpu_num_vgpr" }, |
| 204 | {AttributeCommonInfo::AS_CXX11, "clang::amdgpu_num_vgpr" }, |
| 205 | }; |
| 206 | struct ParsedAttrInfoAMDGPUNumVGPR final : public ParsedAttrInfo { |
| 207 | ParsedAttrInfoAMDGPUNumVGPR() { |
| 208 | AttrKind = ParsedAttr::AT_AMDGPUNumVGPR; |
| 209 | NumArgs = 1; |
| 210 | OptArgs = 0; |
| 211 | HasCustomParsing = 0; |
| 212 | IsTargetSpecific = 0; |
| 213 | IsType = 0; |
| 214 | IsStmt = 0; |
| 215 | IsKnownToGCC = 0; |
| 216 | IsSupportedByPragmaAttribute = 1; |
| 217 | Spellings = AMDGPUNumVGPRSpellings; |
| 218 | } |
| 219 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 220 | if (!isa<FunctionDecl>(D)) { |
| 221 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 222 | << Attr << "kernel functions" ; |
| 223 | return false; |
| 224 | } |
| 225 | return true; |
| 226 | } |
| 227 | |
| 228 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 229 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 230 | } |
| 231 | |
| 232 | static const ParsedAttrInfoAMDGPUNumVGPR Instance; |
| 233 | }; |
| 234 | const ParsedAttrInfoAMDGPUNumVGPR ParsedAttrInfoAMDGPUNumVGPR::Instance; |
| 235 | static constexpr ParsedAttrInfo::Spelling AMDGPUWavesPerEUSpellings[] = { |
| 236 | {AttributeCommonInfo::AS_GNU, "amdgpu_waves_per_eu" }, |
| 237 | {AttributeCommonInfo::AS_CXX11, "clang::amdgpu_waves_per_eu" }, |
| 238 | }; |
| 239 | struct ParsedAttrInfoAMDGPUWavesPerEU final : public ParsedAttrInfo { |
| 240 | ParsedAttrInfoAMDGPUWavesPerEU() { |
| 241 | AttrKind = ParsedAttr::AT_AMDGPUWavesPerEU; |
| 242 | NumArgs = 1; |
| 243 | OptArgs = 1; |
| 244 | HasCustomParsing = 0; |
| 245 | IsTargetSpecific = 0; |
| 246 | IsType = 0; |
| 247 | IsStmt = 0; |
| 248 | IsKnownToGCC = 0; |
| 249 | IsSupportedByPragmaAttribute = 1; |
| 250 | Spellings = AMDGPUWavesPerEUSpellings; |
| 251 | } |
| 252 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 253 | if (!isa<FunctionDecl>(D)) { |
| 254 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 255 | << Attr << "kernel functions" ; |
| 256 | return false; |
| 257 | } |
| 258 | return true; |
| 259 | } |
| 260 | |
| 261 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 262 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 263 | } |
| 264 | |
| 265 | static const ParsedAttrInfoAMDGPUWavesPerEU Instance; |
| 266 | }; |
| 267 | const ParsedAttrInfoAMDGPUWavesPerEU ParsedAttrInfoAMDGPUWavesPerEU::Instance; |
| 268 | static constexpr ParsedAttrInfo::Spelling InterruptSpellings[] = { |
| 269 | {AttributeCommonInfo::AS_GNU, "interrupt" }, |
| 270 | {AttributeCommonInfo::AS_CXX11, "gnu::interrupt" }, |
| 271 | {AttributeCommonInfo::AS_C2x, "gnu::interrupt" }, |
| 272 | }; |
| 273 | struct ParsedAttrInfoInterrupt final : public ParsedAttrInfo { |
| 274 | ParsedAttrInfoInterrupt() { |
| 275 | AttrKind = ParsedAttr::AT_Interrupt; |
| 276 | NumArgs = 0; |
| 277 | OptArgs = 1; |
| 278 | HasCustomParsing = 1; |
| 279 | IsTargetSpecific = 1; |
| 280 | IsType = 0; |
| 281 | IsStmt = 0; |
| 282 | IsKnownToGCC = 1; |
| 283 | IsSupportedByPragmaAttribute = 0; |
| 284 | Spellings = InterruptSpellings; |
| 285 | } |
| 286 | bool existsInTarget(const TargetInfo &Target) const override { |
| 287 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 288 | return true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb || T.getArch() == llvm::Triple::avr || T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64 || T.getArch() == llvm::Triple::msp430 || T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel || T.getArch() == llvm::Triple::riscv32 || T.getArch() == llvm::Triple::riscv64); |
| 289 | } |
| 290 | |
| 291 | static const ParsedAttrInfoInterrupt Instance; |
| 292 | }; |
| 293 | const ParsedAttrInfoInterrupt ParsedAttrInfoInterrupt::Instance; |
| 294 | static constexpr ParsedAttrInfo::Spelling AVRSignalSpellings[] = { |
| 295 | {AttributeCommonInfo::AS_GNU, "signal" }, |
| 296 | {AttributeCommonInfo::AS_CXX11, "gnu::signal" }, |
| 297 | {AttributeCommonInfo::AS_C2x, "gnu::signal" }, |
| 298 | }; |
| 299 | struct ParsedAttrInfoAVRSignal final : public ParsedAttrInfo { |
| 300 | ParsedAttrInfoAVRSignal() { |
| 301 | AttrKind = ParsedAttr::AT_AVRSignal; |
| 302 | NumArgs = 0; |
| 303 | OptArgs = 0; |
| 304 | HasCustomParsing = 0; |
| 305 | IsTargetSpecific = 1; |
| 306 | IsType = 0; |
| 307 | IsStmt = 0; |
| 308 | IsKnownToGCC = 1; |
| 309 | IsSupportedByPragmaAttribute = 1; |
| 310 | Spellings = AVRSignalSpellings; |
| 311 | } |
| 312 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 313 | if (!isa<FunctionDecl>(D)) { |
| 314 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 315 | << Attr << "functions" ; |
| 316 | return false; |
| 317 | } |
| 318 | return true; |
| 319 | } |
| 320 | |
| 321 | bool existsInTarget(const TargetInfo &Target) const override { |
| 322 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 323 | return true && (T.getArch() == llvm::Triple::avr); |
| 324 | } |
| 325 | |
| 326 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 327 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 328 | } |
| 329 | |
| 330 | static const ParsedAttrInfoAVRSignal Instance; |
| 331 | }; |
| 332 | const ParsedAttrInfoAVRSignal ParsedAttrInfoAVRSignal::Instance; |
| 333 | static constexpr ParsedAttrInfo::Spelling AbiTagSpellings[] = { |
| 334 | {AttributeCommonInfo::AS_GNU, "abi_tag" }, |
| 335 | {AttributeCommonInfo::AS_CXX11, "gnu::abi_tag" }, |
| 336 | }; |
| 337 | struct ParsedAttrInfoAbiTag final : public ParsedAttrInfo { |
| 338 | ParsedAttrInfoAbiTag() { |
| 339 | AttrKind = ParsedAttr::AT_AbiTag; |
| 340 | NumArgs = 0; |
| 341 | OptArgs = 15; |
| 342 | HasCustomParsing = 0; |
| 343 | IsTargetSpecific = 0; |
| 344 | IsType = 0; |
| 345 | IsStmt = 0; |
| 346 | IsKnownToGCC = 1; |
| 347 | IsSupportedByPragmaAttribute = 1; |
| 348 | Spellings = AbiTagSpellings; |
| 349 | } |
| 350 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 351 | if (!isStruct(D) && !isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<NamespaceDecl>(D)) { |
| 352 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 353 | << Attr << "structs, variables, functions, and namespaces" ; |
| 354 | return false; |
| 355 | } |
| 356 | return true; |
| 357 | } |
| 358 | |
| 359 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 360 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record_not_is_union, /*IsSupported=*/true)); |
| 361 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 362 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 363 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_namespace, /*IsSupported=*/LangOpts.CPlusPlus)); |
| 364 | } |
| 365 | |
| 366 | static const ParsedAttrInfoAbiTag Instance; |
| 367 | }; |
| 368 | const ParsedAttrInfoAbiTag ParsedAttrInfoAbiTag::Instance; |
| 369 | static constexpr ParsedAttrInfo::Spelling AcquireCapabilitySpellings[] = { |
| 370 | {AttributeCommonInfo::AS_GNU, "acquire_capability" }, |
| 371 | {AttributeCommonInfo::AS_CXX11, "clang::acquire_capability" }, |
| 372 | {AttributeCommonInfo::AS_GNU, "acquire_shared_capability" }, |
| 373 | {AttributeCommonInfo::AS_CXX11, "clang::acquire_shared_capability" }, |
| 374 | {AttributeCommonInfo::AS_GNU, "exclusive_lock_function" }, |
| 375 | {AttributeCommonInfo::AS_GNU, "shared_lock_function" }, |
| 376 | }; |
| 377 | struct ParsedAttrInfoAcquireCapability final : public ParsedAttrInfo { |
| 378 | ParsedAttrInfoAcquireCapability() { |
| 379 | AttrKind = ParsedAttr::AT_AcquireCapability; |
| 380 | NumArgs = 0; |
| 381 | OptArgs = 15; |
| 382 | HasCustomParsing = 0; |
| 383 | IsTargetSpecific = 0; |
| 384 | IsType = 0; |
| 385 | IsStmt = 0; |
| 386 | IsKnownToGCC = 0; |
| 387 | IsSupportedByPragmaAttribute = 0; |
| 388 | Spellings = AcquireCapabilitySpellings; |
| 389 | } |
| 390 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 391 | if (!isa<FunctionDecl>(D)) { |
| 392 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 393 | << Attr << "functions" ; |
| 394 | return false; |
| 395 | } |
| 396 | return true; |
| 397 | } |
| 398 | |
| 399 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 400 | enum Spelling { |
| 401 | GNU_acquire_capability = 0, |
| 402 | CXX11_clang_acquire_capability = 1, |
| 403 | GNU_acquire_shared_capability = 2, |
| 404 | CXX11_clang_acquire_shared_capability = 3, |
| 405 | GNU_exclusive_lock_function = 4, |
| 406 | GNU_shared_lock_function = 5, |
| 407 | SpellingNotCalculated = 15 |
| 408 | |
| 409 | }; |
| 410 | |
| 411 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 412 | switch (Idx) { |
| 413 | default: llvm_unreachable("Unknown spelling list index" ); |
| 414 | case 0: return GNU_acquire_capability; |
| 415 | case 1: return CXX11_clang_acquire_capability; |
| 416 | case 2: return GNU_acquire_shared_capability; |
| 417 | case 3: return CXX11_clang_acquire_shared_capability; |
| 418 | case 4: return GNU_exclusive_lock_function; |
| 419 | case 5: return GNU_shared_lock_function; |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | static const ParsedAttrInfoAcquireCapability Instance; |
| 424 | }; |
| 425 | const ParsedAttrInfoAcquireCapability ParsedAttrInfoAcquireCapability::Instance; |
| 426 | static constexpr ParsedAttrInfo::Spelling AcquireHandleSpellings[] = { |
| 427 | {AttributeCommonInfo::AS_GNU, "acquire_handle" }, |
| 428 | {AttributeCommonInfo::AS_CXX11, "clang::acquire_handle" }, |
| 429 | {AttributeCommonInfo::AS_C2x, "clang::acquire_handle" }, |
| 430 | }; |
| 431 | struct ParsedAttrInfoAcquireHandle final : public ParsedAttrInfo { |
| 432 | ParsedAttrInfoAcquireHandle() { |
| 433 | AttrKind = ParsedAttr::AT_AcquireHandle; |
| 434 | NumArgs = 1; |
| 435 | OptArgs = 0; |
| 436 | HasCustomParsing = 0; |
| 437 | IsTargetSpecific = 0; |
| 438 | IsType = 1; |
| 439 | IsStmt = 0; |
| 440 | IsKnownToGCC = 0; |
| 441 | IsSupportedByPragmaAttribute = 1; |
| 442 | Spellings = AcquireHandleSpellings; |
| 443 | } |
| 444 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 445 | if (!isa<FunctionDecl>(D) && !isa<TypedefNameDecl>(D) && !isa<ParmVarDecl>(D)) { |
| 446 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 447 | << Attr << "functions, typedefs, and parameters" ; |
| 448 | return false; |
| 449 | } |
| 450 | return true; |
| 451 | } |
| 452 | |
| 453 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 454 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 455 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
| 456 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 457 | } |
| 458 | |
| 459 | static const ParsedAttrInfoAcquireHandle Instance; |
| 460 | }; |
| 461 | const ParsedAttrInfoAcquireHandle ParsedAttrInfoAcquireHandle::Instance; |
| 462 | static constexpr ParsedAttrInfo::Spelling AcquiredAfterSpellings[] = { |
| 463 | {AttributeCommonInfo::AS_GNU, "acquired_after" }, |
| 464 | }; |
| 465 | struct ParsedAttrInfoAcquiredAfter final : public ParsedAttrInfo { |
| 466 | ParsedAttrInfoAcquiredAfter() { |
| 467 | AttrKind = ParsedAttr::AT_AcquiredAfter; |
| 468 | NumArgs = 0; |
| 469 | OptArgs = 15; |
| 470 | HasCustomParsing = 0; |
| 471 | IsTargetSpecific = 0; |
| 472 | IsType = 0; |
| 473 | IsStmt = 0; |
| 474 | IsKnownToGCC = 0; |
| 475 | IsSupportedByPragmaAttribute = 0; |
| 476 | Spellings = AcquiredAfterSpellings; |
| 477 | } |
| 478 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 479 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
| 480 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 481 | << Attr << "non-static data members and global variables" ; |
| 482 | return false; |
| 483 | } |
| 484 | return true; |
| 485 | } |
| 486 | |
| 487 | static const ParsedAttrInfoAcquiredAfter Instance; |
| 488 | }; |
| 489 | const ParsedAttrInfoAcquiredAfter ParsedAttrInfoAcquiredAfter::Instance; |
| 490 | static constexpr ParsedAttrInfo::Spelling AcquiredBeforeSpellings[] = { |
| 491 | {AttributeCommonInfo::AS_GNU, "acquired_before" }, |
| 492 | }; |
| 493 | struct ParsedAttrInfoAcquiredBefore final : public ParsedAttrInfo { |
| 494 | ParsedAttrInfoAcquiredBefore() { |
| 495 | AttrKind = ParsedAttr::AT_AcquiredBefore; |
| 496 | NumArgs = 0; |
| 497 | OptArgs = 15; |
| 498 | HasCustomParsing = 0; |
| 499 | IsTargetSpecific = 0; |
| 500 | IsType = 0; |
| 501 | IsStmt = 0; |
| 502 | IsKnownToGCC = 0; |
| 503 | IsSupportedByPragmaAttribute = 0; |
| 504 | Spellings = AcquiredBeforeSpellings; |
| 505 | } |
| 506 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 507 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
| 508 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 509 | << Attr << "non-static data members and global variables" ; |
| 510 | return false; |
| 511 | } |
| 512 | return true; |
| 513 | } |
| 514 | |
| 515 | static const ParsedAttrInfoAcquiredBefore Instance; |
| 516 | }; |
| 517 | const ParsedAttrInfoAcquiredBefore ParsedAttrInfoAcquiredBefore::Instance; |
| 518 | static constexpr ParsedAttrInfo::Spelling AddressSpaceSpellings[] = { |
| 519 | {AttributeCommonInfo::AS_GNU, "address_space" }, |
| 520 | {AttributeCommonInfo::AS_CXX11, "clang::address_space" }, |
| 521 | {AttributeCommonInfo::AS_C2x, "clang::address_space" }, |
| 522 | }; |
| 523 | struct ParsedAttrInfoAddressSpace final : public ParsedAttrInfo { |
| 524 | ParsedAttrInfoAddressSpace() { |
| 525 | AttrKind = ParsedAttr::AT_AddressSpace; |
| 526 | NumArgs = 1; |
| 527 | OptArgs = 0; |
| 528 | HasCustomParsing = 0; |
| 529 | IsTargetSpecific = 0; |
| 530 | IsType = 1; |
| 531 | IsStmt = 0; |
| 532 | IsKnownToGCC = 0; |
| 533 | IsSupportedByPragmaAttribute = 0; |
| 534 | Spellings = AddressSpaceSpellings; |
| 535 | } |
| 536 | static const ParsedAttrInfoAddressSpace Instance; |
| 537 | }; |
| 538 | const ParsedAttrInfoAddressSpace ParsedAttrInfoAddressSpace::Instance; |
| 539 | static constexpr ParsedAttrInfo::Spelling AliasSpellings[] = { |
| 540 | {AttributeCommonInfo::AS_GNU, "alias" }, |
| 541 | {AttributeCommonInfo::AS_CXX11, "gnu::alias" }, |
| 542 | {AttributeCommonInfo::AS_C2x, "gnu::alias" }, |
| 543 | }; |
| 544 | struct ParsedAttrInfoAlias final : public ParsedAttrInfo { |
| 545 | ParsedAttrInfoAlias() { |
| 546 | AttrKind = ParsedAttr::AT_Alias; |
| 547 | NumArgs = 1; |
| 548 | OptArgs = 0; |
| 549 | HasCustomParsing = 0; |
| 550 | IsTargetSpecific = 0; |
| 551 | IsType = 0; |
| 552 | IsStmt = 0; |
| 553 | IsKnownToGCC = 1; |
| 554 | IsSupportedByPragmaAttribute = 1; |
| 555 | Spellings = AliasSpellings; |
| 556 | } |
| 557 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 558 | if (!isa<FunctionDecl>(D) && !isGlobalVar(D)) { |
| 559 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 560 | << Attr << "functions and global variables" ; |
| 561 | return false; |
| 562 | } |
| 563 | return true; |
| 564 | } |
| 565 | |
| 566 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 567 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 568 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
| 569 | } |
| 570 | |
| 571 | static const ParsedAttrInfoAlias Instance; |
| 572 | }; |
| 573 | const ParsedAttrInfoAlias ParsedAttrInfoAlias::Instance; |
| 574 | static constexpr ParsedAttrInfo::Spelling AlignValueSpellings[] = { |
| 575 | {AttributeCommonInfo::AS_GNU, "align_value" }, |
| 576 | }; |
| 577 | struct ParsedAttrInfoAlignValue final : public ParsedAttrInfo { |
| 578 | ParsedAttrInfoAlignValue() { |
| 579 | AttrKind = ParsedAttr::AT_AlignValue; |
| 580 | NumArgs = 1; |
| 581 | OptArgs = 0; |
| 582 | HasCustomParsing = 0; |
| 583 | IsTargetSpecific = 0; |
| 584 | IsType = 0; |
| 585 | IsStmt = 0; |
| 586 | IsKnownToGCC = 0; |
| 587 | IsSupportedByPragmaAttribute = 1; |
| 588 | Spellings = AlignValueSpellings; |
| 589 | } |
| 590 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 591 | if (!isa<VarDecl>(D) && !isa<TypedefNameDecl>(D)) { |
| 592 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 593 | << Attr << "variables and typedefs" ; |
| 594 | return false; |
| 595 | } |
| 596 | return true; |
| 597 | } |
| 598 | |
| 599 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 600 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 601 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
| 602 | } |
| 603 | |
| 604 | static const ParsedAttrInfoAlignValue Instance; |
| 605 | }; |
| 606 | const ParsedAttrInfoAlignValue ParsedAttrInfoAlignValue::Instance; |
| 607 | static constexpr ParsedAttrInfo::Spelling AlignedSpellings[] = { |
| 608 | {AttributeCommonInfo::AS_GNU, "aligned" }, |
| 609 | {AttributeCommonInfo::AS_CXX11, "gnu::aligned" }, |
| 610 | {AttributeCommonInfo::AS_C2x, "gnu::aligned" }, |
| 611 | {AttributeCommonInfo::AS_Declspec, "align" }, |
| 612 | {AttributeCommonInfo::AS_Keyword, "alignas" }, |
| 613 | {AttributeCommonInfo::AS_Keyword, "_Alignas" }, |
| 614 | }; |
| 615 | struct ParsedAttrInfoAligned final : public ParsedAttrInfo { |
| 616 | ParsedAttrInfoAligned() { |
| 617 | AttrKind = ParsedAttr::AT_Aligned; |
| 618 | NumArgs = 0; |
| 619 | OptArgs = 1; |
| 620 | HasCustomParsing = 0; |
| 621 | IsTargetSpecific = 0; |
| 622 | IsType = 0; |
| 623 | IsStmt = 0; |
| 624 | IsKnownToGCC = 1; |
| 625 | IsSupportedByPragmaAttribute = 0; |
| 626 | Spellings = AlignedSpellings; |
| 627 | } |
| 628 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 629 | enum Spelling { |
| 630 | GNU_aligned = 0, |
| 631 | CXX11_gnu_aligned = 1, |
| 632 | C2x_gnu_aligned = 2, |
| 633 | Declspec_align = 3, |
| 634 | Keyword_alignas = 4, |
| 635 | Keyword_Alignas = 5, |
| 636 | SpellingNotCalculated = 15 |
| 637 | |
| 638 | }; |
| 639 | |
| 640 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 641 | switch (Idx) { |
| 642 | default: llvm_unreachable("Unknown spelling list index" ); |
| 643 | case 0: return GNU_aligned; |
| 644 | case 1: return CXX11_gnu_aligned; |
| 645 | case 2: return C2x_gnu_aligned; |
| 646 | case 3: return Declspec_align; |
| 647 | case 4: return Keyword_alignas; |
| 648 | case 5: return Keyword_Alignas; |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | static const ParsedAttrInfoAligned Instance; |
| 653 | }; |
| 654 | const ParsedAttrInfoAligned ParsedAttrInfoAligned::Instance; |
| 655 | static constexpr ParsedAttrInfo::Spelling AllocAlignSpellings[] = { |
| 656 | {AttributeCommonInfo::AS_GNU, "alloc_align" }, |
| 657 | {AttributeCommonInfo::AS_CXX11, "gnu::alloc_align" }, |
| 658 | {AttributeCommonInfo::AS_C2x, "gnu::alloc_align" }, |
| 659 | }; |
| 660 | struct ParsedAttrInfoAllocAlign final : public ParsedAttrInfo { |
| 661 | ParsedAttrInfoAllocAlign() { |
| 662 | AttrKind = ParsedAttr::AT_AllocAlign; |
| 663 | NumArgs = 1; |
| 664 | OptArgs = 0; |
| 665 | HasCustomParsing = 0; |
| 666 | IsTargetSpecific = 0; |
| 667 | IsType = 0; |
| 668 | IsStmt = 0; |
| 669 | IsKnownToGCC = 1; |
| 670 | IsSupportedByPragmaAttribute = 0; |
| 671 | Spellings = AllocAlignSpellings; |
| 672 | } |
| 673 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 674 | if (!isHasFunctionProto(D)) { |
| 675 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 676 | << Attr << "non-K&R-style functions" ; |
| 677 | return false; |
| 678 | } |
| 679 | return true; |
| 680 | } |
| 681 | |
| 682 | static const ParsedAttrInfoAllocAlign Instance; |
| 683 | }; |
| 684 | const ParsedAttrInfoAllocAlign ParsedAttrInfoAllocAlign::Instance; |
| 685 | static constexpr ParsedAttrInfo::Spelling AllocSizeSpellings[] = { |
| 686 | {AttributeCommonInfo::AS_GNU, "alloc_size" }, |
| 687 | {AttributeCommonInfo::AS_CXX11, "gnu::alloc_size" }, |
| 688 | {AttributeCommonInfo::AS_C2x, "gnu::alloc_size" }, |
| 689 | }; |
| 690 | struct ParsedAttrInfoAllocSize final : public ParsedAttrInfo { |
| 691 | ParsedAttrInfoAllocSize() { |
| 692 | AttrKind = ParsedAttr::AT_AllocSize; |
| 693 | NumArgs = 1; |
| 694 | OptArgs = 1; |
| 695 | HasCustomParsing = 0; |
| 696 | IsTargetSpecific = 0; |
| 697 | IsType = 0; |
| 698 | IsStmt = 0; |
| 699 | IsKnownToGCC = 1; |
| 700 | IsSupportedByPragmaAttribute = 1; |
| 701 | Spellings = AllocSizeSpellings; |
| 702 | } |
| 703 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 704 | if (!isa<FunctionDecl>(D)) { |
| 705 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 706 | << Attr << "functions" ; |
| 707 | return false; |
| 708 | } |
| 709 | return true; |
| 710 | } |
| 711 | |
| 712 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 713 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 714 | } |
| 715 | |
| 716 | static const ParsedAttrInfoAllocSize Instance; |
| 717 | }; |
| 718 | const ParsedAttrInfoAllocSize ParsedAttrInfoAllocSize::Instance; |
| 719 | static constexpr ParsedAttrInfo::Spelling AlwaysDestroySpellings[] = { |
| 720 | {AttributeCommonInfo::AS_GNU, "always_destroy" }, |
| 721 | {AttributeCommonInfo::AS_CXX11, "clang::always_destroy" }, |
| 722 | }; |
| 723 | struct ParsedAttrInfoAlwaysDestroy final : public ParsedAttrInfo { |
| 724 | ParsedAttrInfoAlwaysDestroy() { |
| 725 | AttrKind = ParsedAttr::AT_AlwaysDestroy; |
| 726 | NumArgs = 0; |
| 727 | OptArgs = 0; |
| 728 | HasCustomParsing = 0; |
| 729 | IsTargetSpecific = 0; |
| 730 | IsType = 0; |
| 731 | IsStmt = 0; |
| 732 | IsKnownToGCC = 0; |
| 733 | IsSupportedByPragmaAttribute = 1; |
| 734 | Spellings = AlwaysDestroySpellings; |
| 735 | } |
| 736 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 737 | if (!isa<VarDecl>(D)) { |
| 738 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 739 | << Attr << "variables" ; |
| 740 | return false; |
| 741 | } |
| 742 | return true; |
| 743 | } |
| 744 | |
| 745 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 746 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 747 | } |
| 748 | |
| 749 | static const ParsedAttrInfoAlwaysDestroy Instance; |
| 750 | }; |
| 751 | const ParsedAttrInfoAlwaysDestroy ParsedAttrInfoAlwaysDestroy::Instance; |
| 752 | static constexpr ParsedAttrInfo::Spelling AlwaysInlineSpellings[] = { |
| 753 | {AttributeCommonInfo::AS_GNU, "always_inline" }, |
| 754 | {AttributeCommonInfo::AS_CXX11, "gnu::always_inline" }, |
| 755 | {AttributeCommonInfo::AS_C2x, "gnu::always_inline" }, |
| 756 | {AttributeCommonInfo::AS_Keyword, "__forceinline" }, |
| 757 | }; |
| 758 | struct ParsedAttrInfoAlwaysInline final : public ParsedAttrInfo { |
| 759 | ParsedAttrInfoAlwaysInline() { |
| 760 | AttrKind = ParsedAttr::AT_AlwaysInline; |
| 761 | NumArgs = 0; |
| 762 | OptArgs = 0; |
| 763 | HasCustomParsing = 0; |
| 764 | IsTargetSpecific = 0; |
| 765 | IsType = 0; |
| 766 | IsStmt = 0; |
| 767 | IsKnownToGCC = 1; |
| 768 | IsSupportedByPragmaAttribute = 1; |
| 769 | Spellings = AlwaysInlineSpellings; |
| 770 | } |
| 771 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 772 | if (!isa<FunctionDecl>(D)) { |
| 773 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 774 | << Attr << "functions" ; |
| 775 | return false; |
| 776 | } |
| 777 | return true; |
| 778 | } |
| 779 | |
| 780 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 781 | enum Spelling { |
| 782 | GNU_always_inline = 0, |
| 783 | CXX11_gnu_always_inline = 1, |
| 784 | C2x_gnu_always_inline = 2, |
| 785 | Keyword_forceinline = 3, |
| 786 | SpellingNotCalculated = 15 |
| 787 | |
| 788 | }; |
| 789 | |
| 790 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 791 | switch (Idx) { |
| 792 | default: llvm_unreachable("Unknown spelling list index" ); |
| 793 | case 0: return GNU_always_inline; |
| 794 | case 1: return CXX11_gnu_always_inline; |
| 795 | case 2: return C2x_gnu_always_inline; |
| 796 | case 3: return Keyword_forceinline; |
| 797 | } |
| 798 | } |
| 799 | |
| 800 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 801 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 802 | } |
| 803 | |
| 804 | static const ParsedAttrInfoAlwaysInline Instance; |
| 805 | }; |
| 806 | const ParsedAttrInfoAlwaysInline ParsedAttrInfoAlwaysInline::Instance; |
| 807 | static constexpr ParsedAttrInfo::Spelling AnalyzerNoReturnSpellings[] = { |
| 808 | {AttributeCommonInfo::AS_GNU, "analyzer_noreturn" }, |
| 809 | }; |
| 810 | struct ParsedAttrInfoAnalyzerNoReturn final : public ParsedAttrInfo { |
| 811 | ParsedAttrInfoAnalyzerNoReturn() { |
| 812 | AttrKind = ParsedAttr::AT_AnalyzerNoReturn; |
| 813 | NumArgs = 0; |
| 814 | OptArgs = 0; |
| 815 | HasCustomParsing = 0; |
| 816 | IsTargetSpecific = 0; |
| 817 | IsType = 0; |
| 818 | IsStmt = 0; |
| 819 | IsKnownToGCC = 0; |
| 820 | IsSupportedByPragmaAttribute = 0; |
| 821 | Spellings = AnalyzerNoReturnSpellings; |
| 822 | } |
| 823 | static const ParsedAttrInfoAnalyzerNoReturn Instance; |
| 824 | }; |
| 825 | const ParsedAttrInfoAnalyzerNoReturn ParsedAttrInfoAnalyzerNoReturn::Instance; |
| 826 | static constexpr ParsedAttrInfo::Spelling AnnotateSpellings[] = { |
| 827 | {AttributeCommonInfo::AS_GNU, "annotate" }, |
| 828 | {AttributeCommonInfo::AS_CXX11, "clang::annotate" }, |
| 829 | {AttributeCommonInfo::AS_C2x, "clang::annotate" }, |
| 830 | }; |
| 831 | struct ParsedAttrInfoAnnotate final : public ParsedAttrInfo { |
| 832 | ParsedAttrInfoAnnotate() { |
| 833 | AttrKind = ParsedAttr::AT_Annotate; |
| 834 | NumArgs = 1; |
| 835 | OptArgs = 15; |
| 836 | HasCustomParsing = 0; |
| 837 | IsTargetSpecific = 0; |
| 838 | IsType = 0; |
| 839 | IsStmt = 0; |
| 840 | IsKnownToGCC = 0; |
| 841 | IsSupportedByPragmaAttribute = 1; |
| 842 | Spellings = AnnotateSpellings; |
| 843 | } |
| 844 | static const ParsedAttrInfoAnnotate Instance; |
| 845 | }; |
| 846 | const ParsedAttrInfoAnnotate ParsedAttrInfoAnnotate::Instance; |
| 847 | static constexpr ParsedAttrInfo::Spelling [] = { |
| 848 | {AttributeCommonInfo::AS_GNU, "no_caller_saved_registers" }, |
| 849 | {AttributeCommonInfo::AS_CXX11, "gnu::no_caller_saved_registers" }, |
| 850 | {AttributeCommonInfo::AS_C2x, "gnu::no_caller_saved_registers" }, |
| 851 | }; |
| 852 | struct ParsedAttrInfoAnyX86NoCallerSavedRegisters final : public ParsedAttrInfo { |
| 853 | ParsedAttrInfoAnyX86NoCallerSavedRegisters() { |
| 854 | AttrKind = ParsedAttr::AT_AnyX86NoCallerSavedRegisters; |
| 855 | NumArgs = 0; |
| 856 | OptArgs = 0; |
| 857 | HasCustomParsing = 0; |
| 858 | IsTargetSpecific = 1; |
| 859 | IsType = 0; |
| 860 | IsStmt = 0; |
| 861 | IsKnownToGCC = 1; |
| 862 | IsSupportedByPragmaAttribute = 0; |
| 863 | Spellings = AnyX86NoCallerSavedRegistersSpellings; |
| 864 | } |
| 865 | bool existsInTarget(const TargetInfo &Target) const override { |
| 866 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 867 | return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64); |
| 868 | } |
| 869 | |
| 870 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 871 | D->addAttr(::new (S.Context) AnyX86NoCallerSavedRegistersAttr(S.Context, Attr)); |
| 872 | return AttributeApplied; |
| 873 | } |
| 874 | |
| 875 | static const ParsedAttrInfoAnyX86NoCallerSavedRegisters Instance; |
| 876 | }; |
| 877 | const ParsedAttrInfoAnyX86NoCallerSavedRegisters ParsedAttrInfoAnyX86NoCallerSavedRegisters::Instance; |
| 878 | static constexpr ParsedAttrInfo::Spelling AnyX86NoCfCheckSpellings[] = { |
| 879 | {AttributeCommonInfo::AS_GNU, "nocf_check" }, |
| 880 | {AttributeCommonInfo::AS_CXX11, "gnu::nocf_check" }, |
| 881 | {AttributeCommonInfo::AS_C2x, "gnu::nocf_check" }, |
| 882 | }; |
| 883 | struct ParsedAttrInfoAnyX86NoCfCheck final : public ParsedAttrInfo { |
| 884 | ParsedAttrInfoAnyX86NoCfCheck() { |
| 885 | AttrKind = ParsedAttr::AT_AnyX86NoCfCheck; |
| 886 | NumArgs = 0; |
| 887 | OptArgs = 0; |
| 888 | HasCustomParsing = 0; |
| 889 | IsTargetSpecific = 1; |
| 890 | IsType = 1; |
| 891 | IsStmt = 0; |
| 892 | IsKnownToGCC = 1; |
| 893 | IsSupportedByPragmaAttribute = 1; |
| 894 | Spellings = AnyX86NoCfCheckSpellings; |
| 895 | } |
| 896 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 897 | if (!isFunctionLike(D)) { |
| 898 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 899 | << Attr << "functions and function pointers" ; |
| 900 | return false; |
| 901 | } |
| 902 | return true; |
| 903 | } |
| 904 | |
| 905 | bool existsInTarget(const TargetInfo &Target) const override { |
| 906 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 907 | return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64); |
| 908 | } |
| 909 | |
| 910 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 911 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
| 912 | } |
| 913 | |
| 914 | static const ParsedAttrInfoAnyX86NoCfCheck Instance; |
| 915 | }; |
| 916 | const ParsedAttrInfoAnyX86NoCfCheck ParsedAttrInfoAnyX86NoCfCheck::Instance; |
| 917 | static constexpr ParsedAttrInfo::Spelling ArcWeakrefUnavailableSpellings[] = { |
| 918 | {AttributeCommonInfo::AS_GNU, "objc_arc_weak_reference_unavailable" }, |
| 919 | {AttributeCommonInfo::AS_CXX11, "clang::objc_arc_weak_reference_unavailable" }, |
| 920 | {AttributeCommonInfo::AS_C2x, "clang::objc_arc_weak_reference_unavailable" }, |
| 921 | }; |
| 922 | struct ParsedAttrInfoArcWeakrefUnavailable final : public ParsedAttrInfo { |
| 923 | ParsedAttrInfoArcWeakrefUnavailable() { |
| 924 | AttrKind = ParsedAttr::AT_ArcWeakrefUnavailable; |
| 925 | NumArgs = 0; |
| 926 | OptArgs = 0; |
| 927 | HasCustomParsing = 0; |
| 928 | IsTargetSpecific = 0; |
| 929 | IsType = 0; |
| 930 | IsStmt = 0; |
| 931 | IsKnownToGCC = 0; |
| 932 | IsSupportedByPragmaAttribute = 1; |
| 933 | Spellings = ArcWeakrefUnavailableSpellings; |
| 934 | } |
| 935 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 936 | if (!isa<ObjCInterfaceDecl>(D)) { |
| 937 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 938 | << Attr << "Objective-C interfaces" ; |
| 939 | return false; |
| 940 | } |
| 941 | return true; |
| 942 | } |
| 943 | |
| 944 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 945 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 946 | } |
| 947 | |
| 948 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 949 | D->addAttr(::new (S.Context) ArcWeakrefUnavailableAttr(S.Context, Attr)); |
| 950 | return AttributeApplied; |
| 951 | } |
| 952 | |
| 953 | static const ParsedAttrInfoArcWeakrefUnavailable Instance; |
| 954 | }; |
| 955 | const ParsedAttrInfoArcWeakrefUnavailable ParsedAttrInfoArcWeakrefUnavailable::Instance; |
| 956 | static constexpr ParsedAttrInfo::Spelling ArgumentWithTypeTagSpellings[] = { |
| 957 | {AttributeCommonInfo::AS_GNU, "argument_with_type_tag" }, |
| 958 | {AttributeCommonInfo::AS_CXX11, "clang::argument_with_type_tag" }, |
| 959 | {AttributeCommonInfo::AS_C2x, "clang::argument_with_type_tag" }, |
| 960 | {AttributeCommonInfo::AS_GNU, "pointer_with_type_tag" }, |
| 961 | {AttributeCommonInfo::AS_CXX11, "clang::pointer_with_type_tag" }, |
| 962 | {AttributeCommonInfo::AS_C2x, "clang::pointer_with_type_tag" }, |
| 963 | }; |
| 964 | struct ParsedAttrInfoArgumentWithTypeTag final : public ParsedAttrInfo { |
| 965 | ParsedAttrInfoArgumentWithTypeTag() { |
| 966 | AttrKind = ParsedAttr::AT_ArgumentWithTypeTag; |
| 967 | NumArgs = 3; |
| 968 | OptArgs = 0; |
| 969 | HasCustomParsing = 0; |
| 970 | IsTargetSpecific = 0; |
| 971 | IsType = 0; |
| 972 | IsStmt = 0; |
| 973 | IsKnownToGCC = 0; |
| 974 | IsSupportedByPragmaAttribute = 0; |
| 975 | Spellings = ArgumentWithTypeTagSpellings; |
| 976 | } |
| 977 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 978 | if (!isHasFunctionProto(D)) { |
| 979 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 980 | << Attr << "non-K&R-style functions" ; |
| 981 | return false; |
| 982 | } |
| 983 | return true; |
| 984 | } |
| 985 | |
| 986 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 987 | enum Spelling { |
| 988 | GNU_argument_with_type_tag = 0, |
| 989 | CXX11_clang_argument_with_type_tag = 1, |
| 990 | C2x_clang_argument_with_type_tag = 2, |
| 991 | GNU_pointer_with_type_tag = 3, |
| 992 | CXX11_clang_pointer_with_type_tag = 4, |
| 993 | C2x_clang_pointer_with_type_tag = 5, |
| 994 | SpellingNotCalculated = 15 |
| 995 | |
| 996 | }; |
| 997 | |
| 998 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 999 | switch (Idx) { |
| 1000 | default: llvm_unreachable("Unknown spelling list index" ); |
| 1001 | case 0: return GNU_argument_with_type_tag; |
| 1002 | case 1: return CXX11_clang_argument_with_type_tag; |
| 1003 | case 2: return C2x_clang_argument_with_type_tag; |
| 1004 | case 3: return GNU_pointer_with_type_tag; |
| 1005 | case 4: return CXX11_clang_pointer_with_type_tag; |
| 1006 | case 5: return C2x_clang_pointer_with_type_tag; |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | static const ParsedAttrInfoArgumentWithTypeTag Instance; |
| 1011 | }; |
| 1012 | const ParsedAttrInfoArgumentWithTypeTag ParsedAttrInfoArgumentWithTypeTag::Instance; |
| 1013 | static constexpr ParsedAttrInfo::Spelling ArmBuiltinAliasSpellings[] = { |
| 1014 | {AttributeCommonInfo::AS_GNU, "__clang_arm_builtin_alias" }, |
| 1015 | {AttributeCommonInfo::AS_CXX11, "clang::__clang_arm_builtin_alias" }, |
| 1016 | {AttributeCommonInfo::AS_C2x, "clang::__clang_arm_builtin_alias" }, |
| 1017 | }; |
| 1018 | struct ParsedAttrInfoArmBuiltinAlias final : public ParsedAttrInfo { |
| 1019 | ParsedAttrInfoArmBuiltinAlias() { |
| 1020 | AttrKind = ParsedAttr::AT_ArmBuiltinAlias; |
| 1021 | NumArgs = 1; |
| 1022 | OptArgs = 0; |
| 1023 | HasCustomParsing = 0; |
| 1024 | IsTargetSpecific = 1; |
| 1025 | IsType = 0; |
| 1026 | IsStmt = 0; |
| 1027 | IsKnownToGCC = 0; |
| 1028 | IsSupportedByPragmaAttribute = 1; |
| 1029 | Spellings = ArmBuiltinAliasSpellings; |
| 1030 | } |
| 1031 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1032 | if (!isa<FunctionDecl>(D)) { |
| 1033 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 1034 | << Attr << "functions" ; |
| 1035 | return false; |
| 1036 | } |
| 1037 | return true; |
| 1038 | } |
| 1039 | |
| 1040 | bool existsInTarget(const TargetInfo &Target) const override { |
| 1041 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 1042 | return true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb || T.getArch() == llvm::Triple::aarch64); |
| 1043 | } |
| 1044 | |
| 1045 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1046 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1047 | } |
| 1048 | |
| 1049 | static const ParsedAttrInfoArmBuiltinAlias Instance; |
| 1050 | }; |
| 1051 | const ParsedAttrInfoArmBuiltinAlias ParsedAttrInfoArmBuiltinAlias::Instance; |
| 1052 | static constexpr ParsedAttrInfo::Spelling ArmMveStrictPolymorphismSpellings[] = { |
| 1053 | {AttributeCommonInfo::AS_GNU, "__clang_arm_mve_strict_polymorphism" }, |
| 1054 | {AttributeCommonInfo::AS_CXX11, "clang::__clang_arm_mve_strict_polymorphism" }, |
| 1055 | {AttributeCommonInfo::AS_C2x, "clang::__clang_arm_mve_strict_polymorphism" }, |
| 1056 | }; |
| 1057 | struct ParsedAttrInfoArmMveStrictPolymorphism final : public ParsedAttrInfo { |
| 1058 | ParsedAttrInfoArmMveStrictPolymorphism() { |
| 1059 | AttrKind = ParsedAttr::AT_ArmMveStrictPolymorphism; |
| 1060 | NumArgs = 0; |
| 1061 | OptArgs = 0; |
| 1062 | HasCustomParsing = 0; |
| 1063 | IsTargetSpecific = 1; |
| 1064 | IsType = 1; |
| 1065 | IsStmt = 0; |
| 1066 | IsKnownToGCC = 0; |
| 1067 | IsSupportedByPragmaAttribute = 0; |
| 1068 | Spellings = ArmMveStrictPolymorphismSpellings; |
| 1069 | } |
| 1070 | bool existsInTarget(const TargetInfo &Target) const override { |
| 1071 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 1072 | return true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb); |
| 1073 | } |
| 1074 | |
| 1075 | static const ParsedAttrInfoArmMveStrictPolymorphism Instance; |
| 1076 | }; |
| 1077 | const ParsedAttrInfoArmMveStrictPolymorphism ParsedAttrInfoArmMveStrictPolymorphism::Instance; |
| 1078 | static constexpr ParsedAttrInfo::Spelling ArmSveVectorBitsSpellings[] = { |
| 1079 | {AttributeCommonInfo::AS_GNU, "arm_sve_vector_bits" }, |
| 1080 | }; |
| 1081 | struct ParsedAttrInfoArmSveVectorBits final : public ParsedAttrInfo { |
| 1082 | ParsedAttrInfoArmSveVectorBits() { |
| 1083 | AttrKind = ParsedAttr::AT_ArmSveVectorBits; |
| 1084 | NumArgs = 1; |
| 1085 | OptArgs = 0; |
| 1086 | HasCustomParsing = 0; |
| 1087 | IsTargetSpecific = 0; |
| 1088 | IsType = 1; |
| 1089 | IsStmt = 0; |
| 1090 | IsKnownToGCC = 0; |
| 1091 | IsSupportedByPragmaAttribute = 0; |
| 1092 | Spellings = ArmSveVectorBitsSpellings; |
| 1093 | } |
| 1094 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1095 | if (!isa<TypedefNameDecl>(D)) { |
| 1096 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 1097 | << Attr << "typedefs" ; |
| 1098 | return false; |
| 1099 | } |
| 1100 | return true; |
| 1101 | } |
| 1102 | |
| 1103 | static const ParsedAttrInfoArmSveVectorBits Instance; |
| 1104 | }; |
| 1105 | const ParsedAttrInfoArmSveVectorBits ParsedAttrInfoArmSveVectorBits::Instance; |
| 1106 | static constexpr ParsedAttrInfo::Spelling ArtificialSpellings[] = { |
| 1107 | {AttributeCommonInfo::AS_GNU, "artificial" }, |
| 1108 | {AttributeCommonInfo::AS_CXX11, "gnu::artificial" }, |
| 1109 | {AttributeCommonInfo::AS_C2x, "gnu::artificial" }, |
| 1110 | }; |
| 1111 | struct ParsedAttrInfoArtificial final : public ParsedAttrInfo { |
| 1112 | ParsedAttrInfoArtificial() { |
| 1113 | AttrKind = ParsedAttr::AT_Artificial; |
| 1114 | NumArgs = 0; |
| 1115 | OptArgs = 0; |
| 1116 | HasCustomParsing = 0; |
| 1117 | IsTargetSpecific = 0; |
| 1118 | IsType = 0; |
| 1119 | IsStmt = 0; |
| 1120 | IsKnownToGCC = 1; |
| 1121 | IsSupportedByPragmaAttribute = 0; |
| 1122 | Spellings = ArtificialSpellings; |
| 1123 | } |
| 1124 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1125 | if (!isInlineFunction(D)) { |
| 1126 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1127 | << Attr << "inline functions" ; |
| 1128 | return false; |
| 1129 | } |
| 1130 | return true; |
| 1131 | } |
| 1132 | |
| 1133 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 1134 | D->addAttr(::new (S.Context) ArtificialAttr(S.Context, Attr)); |
| 1135 | return AttributeApplied; |
| 1136 | } |
| 1137 | |
| 1138 | static const ParsedAttrInfoArtificial Instance; |
| 1139 | }; |
| 1140 | const ParsedAttrInfoArtificial ParsedAttrInfoArtificial::Instance; |
| 1141 | static constexpr ParsedAttrInfo::Spelling AssertCapabilitySpellings[] = { |
| 1142 | {AttributeCommonInfo::AS_GNU, "assert_capability" }, |
| 1143 | {AttributeCommonInfo::AS_CXX11, "clang::assert_capability" }, |
| 1144 | {AttributeCommonInfo::AS_GNU, "assert_shared_capability" }, |
| 1145 | {AttributeCommonInfo::AS_CXX11, "clang::assert_shared_capability" }, |
| 1146 | }; |
| 1147 | struct ParsedAttrInfoAssertCapability final : public ParsedAttrInfo { |
| 1148 | ParsedAttrInfoAssertCapability() { |
| 1149 | AttrKind = ParsedAttr::AT_AssertCapability; |
| 1150 | NumArgs = 0; |
| 1151 | OptArgs = 15; |
| 1152 | HasCustomParsing = 0; |
| 1153 | IsTargetSpecific = 0; |
| 1154 | IsType = 0; |
| 1155 | IsStmt = 0; |
| 1156 | IsKnownToGCC = 0; |
| 1157 | IsSupportedByPragmaAttribute = 0; |
| 1158 | Spellings = AssertCapabilitySpellings; |
| 1159 | } |
| 1160 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1161 | if (!isa<FunctionDecl>(D)) { |
| 1162 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1163 | << Attr << "functions" ; |
| 1164 | return false; |
| 1165 | } |
| 1166 | return true; |
| 1167 | } |
| 1168 | |
| 1169 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 1170 | enum Spelling { |
| 1171 | GNU_assert_capability = 0, |
| 1172 | CXX11_clang_assert_capability = 1, |
| 1173 | GNU_assert_shared_capability = 2, |
| 1174 | CXX11_clang_assert_shared_capability = 3, |
| 1175 | SpellingNotCalculated = 15 |
| 1176 | |
| 1177 | }; |
| 1178 | |
| 1179 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 1180 | switch (Idx) { |
| 1181 | default: llvm_unreachable("Unknown spelling list index" ); |
| 1182 | case 0: return GNU_assert_capability; |
| 1183 | case 1: return CXX11_clang_assert_capability; |
| 1184 | case 2: return GNU_assert_shared_capability; |
| 1185 | case 3: return CXX11_clang_assert_shared_capability; |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | static const ParsedAttrInfoAssertCapability Instance; |
| 1190 | }; |
| 1191 | const ParsedAttrInfoAssertCapability ParsedAttrInfoAssertCapability::Instance; |
| 1192 | static constexpr ParsedAttrInfo::Spelling AssertExclusiveLockSpellings[] = { |
| 1193 | {AttributeCommonInfo::AS_GNU, "assert_exclusive_lock" }, |
| 1194 | }; |
| 1195 | struct ParsedAttrInfoAssertExclusiveLock final : public ParsedAttrInfo { |
| 1196 | ParsedAttrInfoAssertExclusiveLock() { |
| 1197 | AttrKind = ParsedAttr::AT_AssertExclusiveLock; |
| 1198 | NumArgs = 0; |
| 1199 | OptArgs = 15; |
| 1200 | HasCustomParsing = 0; |
| 1201 | IsTargetSpecific = 0; |
| 1202 | IsType = 0; |
| 1203 | IsStmt = 0; |
| 1204 | IsKnownToGCC = 0; |
| 1205 | IsSupportedByPragmaAttribute = 0; |
| 1206 | Spellings = AssertExclusiveLockSpellings; |
| 1207 | } |
| 1208 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1209 | if (!isa<FunctionDecl>(D)) { |
| 1210 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1211 | << Attr << "functions" ; |
| 1212 | return false; |
| 1213 | } |
| 1214 | return true; |
| 1215 | } |
| 1216 | |
| 1217 | static const ParsedAttrInfoAssertExclusiveLock Instance; |
| 1218 | }; |
| 1219 | const ParsedAttrInfoAssertExclusiveLock ParsedAttrInfoAssertExclusiveLock::Instance; |
| 1220 | static constexpr ParsedAttrInfo::Spelling AssertSharedLockSpellings[] = { |
| 1221 | {AttributeCommonInfo::AS_GNU, "assert_shared_lock" }, |
| 1222 | }; |
| 1223 | struct ParsedAttrInfoAssertSharedLock final : public ParsedAttrInfo { |
| 1224 | ParsedAttrInfoAssertSharedLock() { |
| 1225 | AttrKind = ParsedAttr::AT_AssertSharedLock; |
| 1226 | NumArgs = 0; |
| 1227 | OptArgs = 15; |
| 1228 | HasCustomParsing = 0; |
| 1229 | IsTargetSpecific = 0; |
| 1230 | IsType = 0; |
| 1231 | IsStmt = 0; |
| 1232 | IsKnownToGCC = 0; |
| 1233 | IsSupportedByPragmaAttribute = 0; |
| 1234 | Spellings = AssertSharedLockSpellings; |
| 1235 | } |
| 1236 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1237 | if (!isa<FunctionDecl>(D)) { |
| 1238 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1239 | << Attr << "functions" ; |
| 1240 | return false; |
| 1241 | } |
| 1242 | return true; |
| 1243 | } |
| 1244 | |
| 1245 | static const ParsedAttrInfoAssertSharedLock Instance; |
| 1246 | }; |
| 1247 | const ParsedAttrInfoAssertSharedLock ParsedAttrInfoAssertSharedLock::Instance; |
| 1248 | static constexpr ParsedAttrInfo::Spelling AssumeAlignedSpellings[] = { |
| 1249 | {AttributeCommonInfo::AS_GNU, "assume_aligned" }, |
| 1250 | {AttributeCommonInfo::AS_CXX11, "gnu::assume_aligned" }, |
| 1251 | {AttributeCommonInfo::AS_C2x, "gnu::assume_aligned" }, |
| 1252 | }; |
| 1253 | struct ParsedAttrInfoAssumeAligned final : public ParsedAttrInfo { |
| 1254 | ParsedAttrInfoAssumeAligned() { |
| 1255 | AttrKind = ParsedAttr::AT_AssumeAligned; |
| 1256 | NumArgs = 1; |
| 1257 | OptArgs = 1; |
| 1258 | HasCustomParsing = 0; |
| 1259 | IsTargetSpecific = 0; |
| 1260 | IsType = 0; |
| 1261 | IsStmt = 0; |
| 1262 | IsKnownToGCC = 1; |
| 1263 | IsSupportedByPragmaAttribute = 1; |
| 1264 | Spellings = AssumeAlignedSpellings; |
| 1265 | } |
| 1266 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1267 | if (!isa<ObjCMethodDecl>(D) && !isa<FunctionDecl>(D)) { |
| 1268 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1269 | << Attr << "Objective-C methods and functions" ; |
| 1270 | return false; |
| 1271 | } |
| 1272 | return true; |
| 1273 | } |
| 1274 | |
| 1275 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1276 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 1277 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1278 | } |
| 1279 | |
| 1280 | static const ParsedAttrInfoAssumeAligned Instance; |
| 1281 | }; |
| 1282 | const ParsedAttrInfoAssumeAligned ParsedAttrInfoAssumeAligned::Instance; |
| 1283 | static constexpr ParsedAttrInfo::Spelling AssumptionSpellings[] = { |
| 1284 | {AttributeCommonInfo::AS_GNU, "assume" }, |
| 1285 | {AttributeCommonInfo::AS_CXX11, "clang::assume" }, |
| 1286 | {AttributeCommonInfo::AS_C2x, "clang::assume" }, |
| 1287 | }; |
| 1288 | struct ParsedAttrInfoAssumption final : public ParsedAttrInfo { |
| 1289 | ParsedAttrInfoAssumption() { |
| 1290 | AttrKind = ParsedAttr::AT_Assumption; |
| 1291 | NumArgs = 1; |
| 1292 | OptArgs = 0; |
| 1293 | HasCustomParsing = 0; |
| 1294 | IsTargetSpecific = 0; |
| 1295 | IsType = 0; |
| 1296 | IsStmt = 0; |
| 1297 | IsKnownToGCC = 0; |
| 1298 | IsSupportedByPragmaAttribute = 1; |
| 1299 | Spellings = AssumptionSpellings; |
| 1300 | } |
| 1301 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1302 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 1303 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1304 | << Attr << "functions and Objective-C methods" ; |
| 1305 | return false; |
| 1306 | } |
| 1307 | return true; |
| 1308 | } |
| 1309 | |
| 1310 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1311 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1312 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 1313 | } |
| 1314 | |
| 1315 | static const ParsedAttrInfoAssumption Instance; |
| 1316 | }; |
| 1317 | const ParsedAttrInfoAssumption ParsedAttrInfoAssumption::Instance; |
| 1318 | static constexpr ParsedAttrInfo::Spelling AvailabilitySpellings[] = { |
| 1319 | {AttributeCommonInfo::AS_GNU, "availability" }, |
| 1320 | {AttributeCommonInfo::AS_CXX11, "clang::availability" }, |
| 1321 | {AttributeCommonInfo::AS_C2x, "clang::availability" }, |
| 1322 | }; |
| 1323 | struct ParsedAttrInfoAvailability final : public ParsedAttrInfo { |
| 1324 | ParsedAttrInfoAvailability() { |
| 1325 | AttrKind = ParsedAttr::AT_Availability; |
| 1326 | NumArgs = 9; |
| 1327 | OptArgs = 0; |
| 1328 | HasCustomParsing = 1; |
| 1329 | IsTargetSpecific = 0; |
| 1330 | IsType = 0; |
| 1331 | IsStmt = 0; |
| 1332 | IsKnownToGCC = 0; |
| 1333 | IsSupportedByPragmaAttribute = 1; |
| 1334 | Spellings = AvailabilitySpellings; |
| 1335 | } |
| 1336 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1337 | if (!isa<NamedDecl>(D)) { |
| 1338 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1339 | << Attr << "named declarations" ; |
| 1340 | return false; |
| 1341 | } |
| 1342 | return true; |
| 1343 | } |
| 1344 | |
| 1345 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1346 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 1347 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
| 1348 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum_constant, /*IsSupported=*/true)); |
| 1349 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_field, /*IsSupported=*/true)); |
| 1350 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1351 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_namespace, /*IsSupported=*/LangOpts.CPlusPlus)); |
| 1352 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_category, /*IsSupported=*/LangOpts.ObjC)); |
| 1353 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_implementation, /*IsSupported=*/LangOpts.ObjC)); |
| 1354 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 1355 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 1356 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
| 1357 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC)); |
| 1358 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 1359 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
| 1360 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 1361 | } |
| 1362 | |
| 1363 | static const ParsedAttrInfoAvailability Instance; |
| 1364 | }; |
| 1365 | const ParsedAttrInfoAvailability ParsedAttrInfoAvailability::Instance; |
| 1366 | static constexpr ParsedAttrInfo::Spelling BPFPreserveAccessIndexSpellings[] = { |
| 1367 | {AttributeCommonInfo::AS_GNU, "preserve_access_index" }, |
| 1368 | {AttributeCommonInfo::AS_CXX11, "clang::preserve_access_index" }, |
| 1369 | {AttributeCommonInfo::AS_C2x, "clang::preserve_access_index" }, |
| 1370 | }; |
| 1371 | struct ParsedAttrInfoBPFPreserveAccessIndex final : public ParsedAttrInfo { |
| 1372 | ParsedAttrInfoBPFPreserveAccessIndex() { |
| 1373 | AttrKind = ParsedAttr::AT_BPFPreserveAccessIndex; |
| 1374 | NumArgs = 0; |
| 1375 | OptArgs = 0; |
| 1376 | HasCustomParsing = 0; |
| 1377 | IsTargetSpecific = 1; |
| 1378 | IsType = 0; |
| 1379 | IsStmt = 0; |
| 1380 | IsKnownToGCC = 0; |
| 1381 | IsSupportedByPragmaAttribute = 1; |
| 1382 | Spellings = BPFPreserveAccessIndexSpellings; |
| 1383 | } |
| 1384 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1385 | if (!isa<RecordDecl>(D)) { |
| 1386 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 1387 | << Attr << "structs, unions, and classes" ; |
| 1388 | return false; |
| 1389 | } |
| 1390 | return true; |
| 1391 | } |
| 1392 | |
| 1393 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 1394 | auto &LangOpts = S.LangOpts; |
| 1395 | if ((!LangOpts.CPlusPlus)) |
| 1396 | return true; |
| 1397 | |
| 1398 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 1399 | return false; |
| 1400 | } |
| 1401 | |
| 1402 | bool existsInTarget(const TargetInfo &Target) const override { |
| 1403 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 1404 | return true && (T.getArch() == llvm::Triple::bpfel || T.getArch() == llvm::Triple::bpfeb); |
| 1405 | } |
| 1406 | |
| 1407 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1408 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 1409 | } |
| 1410 | |
| 1411 | static const ParsedAttrInfoBPFPreserveAccessIndex Instance; |
| 1412 | }; |
| 1413 | const ParsedAttrInfoBPFPreserveAccessIndex ParsedAttrInfoBPFPreserveAccessIndex::Instance; |
| 1414 | static constexpr ParsedAttrInfo::Spelling BlocksSpellings[] = { |
| 1415 | {AttributeCommonInfo::AS_GNU, "blocks" }, |
| 1416 | {AttributeCommonInfo::AS_CXX11, "clang::blocks" }, |
| 1417 | {AttributeCommonInfo::AS_C2x, "clang::blocks" }, |
| 1418 | }; |
| 1419 | struct ParsedAttrInfoBlocks final : public ParsedAttrInfo { |
| 1420 | ParsedAttrInfoBlocks() { |
| 1421 | AttrKind = ParsedAttr::AT_Blocks; |
| 1422 | NumArgs = 1; |
| 1423 | OptArgs = 0; |
| 1424 | HasCustomParsing = 0; |
| 1425 | IsTargetSpecific = 0; |
| 1426 | IsType = 0; |
| 1427 | IsStmt = 0; |
| 1428 | IsKnownToGCC = 0; |
| 1429 | IsSupportedByPragmaAttribute = 0; |
| 1430 | Spellings = BlocksSpellings; |
| 1431 | } |
| 1432 | static const ParsedAttrInfoBlocks Instance; |
| 1433 | }; |
| 1434 | const ParsedAttrInfoBlocks ParsedAttrInfoBlocks::Instance; |
| 1435 | static constexpr ParsedAttrInfo::Spelling CDeclSpellings[] = { |
| 1436 | {AttributeCommonInfo::AS_GNU, "cdecl" }, |
| 1437 | {AttributeCommonInfo::AS_CXX11, "gnu::cdecl" }, |
| 1438 | {AttributeCommonInfo::AS_C2x, "gnu::cdecl" }, |
| 1439 | {AttributeCommonInfo::AS_Keyword, "__cdecl" }, |
| 1440 | {AttributeCommonInfo::AS_Keyword, "_cdecl" }, |
| 1441 | }; |
| 1442 | struct ParsedAttrInfoCDecl final : public ParsedAttrInfo { |
| 1443 | ParsedAttrInfoCDecl() { |
| 1444 | AttrKind = ParsedAttr::AT_CDecl; |
| 1445 | NumArgs = 0; |
| 1446 | OptArgs = 0; |
| 1447 | HasCustomParsing = 0; |
| 1448 | IsTargetSpecific = 0; |
| 1449 | IsType = 1; |
| 1450 | IsStmt = 0; |
| 1451 | IsKnownToGCC = 1; |
| 1452 | IsSupportedByPragmaAttribute = 0; |
| 1453 | Spellings = CDeclSpellings; |
| 1454 | } |
| 1455 | static const ParsedAttrInfoCDecl Instance; |
| 1456 | }; |
| 1457 | const ParsedAttrInfoCDecl ParsedAttrInfoCDecl::Instance; |
| 1458 | static constexpr ParsedAttrInfo::Spelling CFAuditedTransferSpellings[] = { |
| 1459 | {AttributeCommonInfo::AS_GNU, "cf_audited_transfer" }, |
| 1460 | {AttributeCommonInfo::AS_CXX11, "clang::cf_audited_transfer" }, |
| 1461 | {AttributeCommonInfo::AS_C2x, "clang::cf_audited_transfer" }, |
| 1462 | }; |
| 1463 | struct ParsedAttrInfoCFAuditedTransfer final : public ParsedAttrInfo { |
| 1464 | ParsedAttrInfoCFAuditedTransfer() { |
| 1465 | AttrKind = ParsedAttr::AT_CFAuditedTransfer; |
| 1466 | NumArgs = 0; |
| 1467 | OptArgs = 0; |
| 1468 | HasCustomParsing = 0; |
| 1469 | IsTargetSpecific = 0; |
| 1470 | IsType = 0; |
| 1471 | IsStmt = 0; |
| 1472 | IsKnownToGCC = 0; |
| 1473 | IsSupportedByPragmaAttribute = 1; |
| 1474 | Spellings = CFAuditedTransferSpellings; |
| 1475 | } |
| 1476 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1477 | if (!isa<FunctionDecl>(D)) { |
| 1478 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 1479 | << Attr << "functions" ; |
| 1480 | return false; |
| 1481 | } |
| 1482 | return true; |
| 1483 | } |
| 1484 | |
| 1485 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1486 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1487 | } |
| 1488 | |
| 1489 | static const ParsedAttrInfoCFAuditedTransfer Instance; |
| 1490 | }; |
| 1491 | const ParsedAttrInfoCFAuditedTransfer ParsedAttrInfoCFAuditedTransfer::Instance; |
| 1492 | static constexpr ParsedAttrInfo::Spelling CFConsumedSpellings[] = { |
| 1493 | {AttributeCommonInfo::AS_GNU, "cf_consumed" }, |
| 1494 | {AttributeCommonInfo::AS_CXX11, "clang::cf_consumed" }, |
| 1495 | {AttributeCommonInfo::AS_C2x, "clang::cf_consumed" }, |
| 1496 | }; |
| 1497 | struct ParsedAttrInfoCFConsumed final : public ParsedAttrInfo { |
| 1498 | ParsedAttrInfoCFConsumed() { |
| 1499 | AttrKind = ParsedAttr::AT_CFConsumed; |
| 1500 | NumArgs = 0; |
| 1501 | OptArgs = 0; |
| 1502 | HasCustomParsing = 0; |
| 1503 | IsTargetSpecific = 0; |
| 1504 | IsType = 0; |
| 1505 | IsStmt = 0; |
| 1506 | IsKnownToGCC = 0; |
| 1507 | IsSupportedByPragmaAttribute = 1; |
| 1508 | Spellings = CFConsumedSpellings; |
| 1509 | } |
| 1510 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1511 | if (!isa<ParmVarDecl>(D)) { |
| 1512 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1513 | << Attr << "parameters" ; |
| 1514 | return false; |
| 1515 | } |
| 1516 | return true; |
| 1517 | } |
| 1518 | |
| 1519 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1520 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 1521 | } |
| 1522 | |
| 1523 | static const ParsedAttrInfoCFConsumed Instance; |
| 1524 | }; |
| 1525 | const ParsedAttrInfoCFConsumed ParsedAttrInfoCFConsumed::Instance; |
| 1526 | static constexpr ParsedAttrInfo::Spelling CFGuardSpellings[] = { |
| 1527 | {AttributeCommonInfo::AS_Declspec, "guard" }, |
| 1528 | }; |
| 1529 | struct ParsedAttrInfoCFGuard final : public ParsedAttrInfo { |
| 1530 | ParsedAttrInfoCFGuard() { |
| 1531 | AttrKind = ParsedAttr::AT_CFGuard; |
| 1532 | NumArgs = 1; |
| 1533 | OptArgs = 0; |
| 1534 | HasCustomParsing = 0; |
| 1535 | IsTargetSpecific = 0; |
| 1536 | IsType = 0; |
| 1537 | IsStmt = 0; |
| 1538 | IsKnownToGCC = 0; |
| 1539 | IsSupportedByPragmaAttribute = 0; |
| 1540 | Spellings = CFGuardSpellings; |
| 1541 | } |
| 1542 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1543 | if (!isa<FunctionDecl>(D)) { |
| 1544 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1545 | << Attr << "functions" ; |
| 1546 | return false; |
| 1547 | } |
| 1548 | return true; |
| 1549 | } |
| 1550 | |
| 1551 | static const ParsedAttrInfoCFGuard Instance; |
| 1552 | }; |
| 1553 | const ParsedAttrInfoCFGuard ParsedAttrInfoCFGuard::Instance; |
| 1554 | static constexpr ParsedAttrInfo::Spelling CFICanonicalJumpTableSpellings[] = { |
| 1555 | {AttributeCommonInfo::AS_GNU, "cfi_canonical_jump_table" }, |
| 1556 | {AttributeCommonInfo::AS_CXX11, "clang::cfi_canonical_jump_table" }, |
| 1557 | {AttributeCommonInfo::AS_C2x, "clang::cfi_canonical_jump_table" }, |
| 1558 | }; |
| 1559 | struct ParsedAttrInfoCFICanonicalJumpTable final : public ParsedAttrInfo { |
| 1560 | ParsedAttrInfoCFICanonicalJumpTable() { |
| 1561 | AttrKind = ParsedAttr::AT_CFICanonicalJumpTable; |
| 1562 | NumArgs = 0; |
| 1563 | OptArgs = 0; |
| 1564 | HasCustomParsing = 0; |
| 1565 | IsTargetSpecific = 0; |
| 1566 | IsType = 0; |
| 1567 | IsStmt = 0; |
| 1568 | IsKnownToGCC = 0; |
| 1569 | IsSupportedByPragmaAttribute = 1; |
| 1570 | Spellings = CFICanonicalJumpTableSpellings; |
| 1571 | } |
| 1572 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1573 | if (!isa<FunctionDecl>(D)) { |
| 1574 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 1575 | << Attr << "functions" ; |
| 1576 | return false; |
| 1577 | } |
| 1578 | return true; |
| 1579 | } |
| 1580 | |
| 1581 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1582 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1583 | } |
| 1584 | |
| 1585 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 1586 | D->addAttr(::new (S.Context) CFICanonicalJumpTableAttr(S.Context, Attr)); |
| 1587 | return AttributeApplied; |
| 1588 | } |
| 1589 | |
| 1590 | static const ParsedAttrInfoCFICanonicalJumpTable Instance; |
| 1591 | }; |
| 1592 | const ParsedAttrInfoCFICanonicalJumpTable ParsedAttrInfoCFICanonicalJumpTable::Instance; |
| 1593 | static constexpr ParsedAttrInfo::Spelling CFReturnsNotRetainedSpellings[] = { |
| 1594 | {AttributeCommonInfo::AS_GNU, "cf_returns_not_retained" }, |
| 1595 | {AttributeCommonInfo::AS_CXX11, "clang::cf_returns_not_retained" }, |
| 1596 | {AttributeCommonInfo::AS_C2x, "clang::cf_returns_not_retained" }, |
| 1597 | }; |
| 1598 | struct ParsedAttrInfoCFReturnsNotRetained final : public ParsedAttrInfo { |
| 1599 | ParsedAttrInfoCFReturnsNotRetained() { |
| 1600 | AttrKind = ParsedAttr::AT_CFReturnsNotRetained; |
| 1601 | NumArgs = 0; |
| 1602 | OptArgs = 0; |
| 1603 | HasCustomParsing = 0; |
| 1604 | IsTargetSpecific = 0; |
| 1605 | IsType = 0; |
| 1606 | IsStmt = 0; |
| 1607 | IsKnownToGCC = 0; |
| 1608 | IsSupportedByPragmaAttribute = 0; |
| 1609 | Spellings = CFReturnsNotRetainedSpellings; |
| 1610 | } |
| 1611 | static const ParsedAttrInfoCFReturnsNotRetained Instance; |
| 1612 | }; |
| 1613 | const ParsedAttrInfoCFReturnsNotRetained ParsedAttrInfoCFReturnsNotRetained::Instance; |
| 1614 | static constexpr ParsedAttrInfo::Spelling CFReturnsRetainedSpellings[] = { |
| 1615 | {AttributeCommonInfo::AS_GNU, "cf_returns_retained" }, |
| 1616 | {AttributeCommonInfo::AS_CXX11, "clang::cf_returns_retained" }, |
| 1617 | {AttributeCommonInfo::AS_C2x, "clang::cf_returns_retained" }, |
| 1618 | }; |
| 1619 | struct ParsedAttrInfoCFReturnsRetained final : public ParsedAttrInfo { |
| 1620 | ParsedAttrInfoCFReturnsRetained() { |
| 1621 | AttrKind = ParsedAttr::AT_CFReturnsRetained; |
| 1622 | NumArgs = 0; |
| 1623 | OptArgs = 0; |
| 1624 | HasCustomParsing = 0; |
| 1625 | IsTargetSpecific = 0; |
| 1626 | IsType = 0; |
| 1627 | IsStmt = 0; |
| 1628 | IsKnownToGCC = 0; |
| 1629 | IsSupportedByPragmaAttribute = 0; |
| 1630 | Spellings = CFReturnsRetainedSpellings; |
| 1631 | } |
| 1632 | static const ParsedAttrInfoCFReturnsRetained Instance; |
| 1633 | }; |
| 1634 | const ParsedAttrInfoCFReturnsRetained ParsedAttrInfoCFReturnsRetained::Instance; |
| 1635 | static constexpr ParsedAttrInfo::Spelling CFUnknownTransferSpellings[] = { |
| 1636 | {AttributeCommonInfo::AS_GNU, "cf_unknown_transfer" }, |
| 1637 | {AttributeCommonInfo::AS_CXX11, "clang::cf_unknown_transfer" }, |
| 1638 | {AttributeCommonInfo::AS_C2x, "clang::cf_unknown_transfer" }, |
| 1639 | }; |
| 1640 | struct ParsedAttrInfoCFUnknownTransfer final : public ParsedAttrInfo { |
| 1641 | ParsedAttrInfoCFUnknownTransfer() { |
| 1642 | AttrKind = ParsedAttr::AT_CFUnknownTransfer; |
| 1643 | NumArgs = 0; |
| 1644 | OptArgs = 0; |
| 1645 | HasCustomParsing = 0; |
| 1646 | IsTargetSpecific = 0; |
| 1647 | IsType = 0; |
| 1648 | IsStmt = 0; |
| 1649 | IsKnownToGCC = 0; |
| 1650 | IsSupportedByPragmaAttribute = 1; |
| 1651 | Spellings = CFUnknownTransferSpellings; |
| 1652 | } |
| 1653 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1654 | if (!isa<FunctionDecl>(D)) { |
| 1655 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 1656 | << Attr << "functions" ; |
| 1657 | return false; |
| 1658 | } |
| 1659 | return true; |
| 1660 | } |
| 1661 | |
| 1662 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1663 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1664 | } |
| 1665 | |
| 1666 | static const ParsedAttrInfoCFUnknownTransfer Instance; |
| 1667 | }; |
| 1668 | const ParsedAttrInfoCFUnknownTransfer ParsedAttrInfoCFUnknownTransfer::Instance; |
| 1669 | static constexpr ParsedAttrInfo::Spelling CPUDispatchSpellings[] = { |
| 1670 | {AttributeCommonInfo::AS_GNU, "cpu_dispatch" }, |
| 1671 | {AttributeCommonInfo::AS_CXX11, "clang::cpu_dispatch" }, |
| 1672 | {AttributeCommonInfo::AS_C2x, "clang::cpu_dispatch" }, |
| 1673 | {AttributeCommonInfo::AS_Declspec, "cpu_dispatch" }, |
| 1674 | }; |
| 1675 | struct ParsedAttrInfoCPUDispatch final : public ParsedAttrInfo { |
| 1676 | ParsedAttrInfoCPUDispatch() { |
| 1677 | AttrKind = ParsedAttr::AT_CPUDispatch; |
| 1678 | NumArgs = 0; |
| 1679 | OptArgs = 15; |
| 1680 | HasCustomParsing = 0; |
| 1681 | IsTargetSpecific = 0; |
| 1682 | IsType = 0; |
| 1683 | IsStmt = 0; |
| 1684 | IsKnownToGCC = 0; |
| 1685 | IsSupportedByPragmaAttribute = 1; |
| 1686 | Spellings = CPUDispatchSpellings; |
| 1687 | } |
| 1688 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1689 | if (!isa<FunctionDecl>(D)) { |
| 1690 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1691 | << Attr << "functions" ; |
| 1692 | return false; |
| 1693 | } |
| 1694 | return true; |
| 1695 | } |
| 1696 | |
| 1697 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1698 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1699 | } |
| 1700 | |
| 1701 | static const ParsedAttrInfoCPUDispatch Instance; |
| 1702 | }; |
| 1703 | const ParsedAttrInfoCPUDispatch ParsedAttrInfoCPUDispatch::Instance; |
| 1704 | static constexpr ParsedAttrInfo::Spelling CPUSpecificSpellings[] = { |
| 1705 | {AttributeCommonInfo::AS_GNU, "cpu_specific" }, |
| 1706 | {AttributeCommonInfo::AS_CXX11, "clang::cpu_specific" }, |
| 1707 | {AttributeCommonInfo::AS_C2x, "clang::cpu_specific" }, |
| 1708 | {AttributeCommonInfo::AS_Declspec, "cpu_specific" }, |
| 1709 | }; |
| 1710 | struct ParsedAttrInfoCPUSpecific final : public ParsedAttrInfo { |
| 1711 | ParsedAttrInfoCPUSpecific() { |
| 1712 | AttrKind = ParsedAttr::AT_CPUSpecific; |
| 1713 | NumArgs = 0; |
| 1714 | OptArgs = 15; |
| 1715 | HasCustomParsing = 0; |
| 1716 | IsTargetSpecific = 0; |
| 1717 | IsType = 0; |
| 1718 | IsStmt = 0; |
| 1719 | IsKnownToGCC = 0; |
| 1720 | IsSupportedByPragmaAttribute = 1; |
| 1721 | Spellings = CPUSpecificSpellings; |
| 1722 | } |
| 1723 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1724 | if (!isa<FunctionDecl>(D)) { |
| 1725 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1726 | << Attr << "functions" ; |
| 1727 | return false; |
| 1728 | } |
| 1729 | return true; |
| 1730 | } |
| 1731 | |
| 1732 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1733 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1734 | } |
| 1735 | |
| 1736 | static const ParsedAttrInfoCPUSpecific Instance; |
| 1737 | }; |
| 1738 | const ParsedAttrInfoCPUSpecific ParsedAttrInfoCPUSpecific::Instance; |
| 1739 | static constexpr ParsedAttrInfo::Spelling CUDAConstantSpellings[] = { |
| 1740 | {AttributeCommonInfo::AS_GNU, "constant" }, |
| 1741 | {AttributeCommonInfo::AS_Declspec, "__constant__" }, |
| 1742 | }; |
| 1743 | struct ParsedAttrInfoCUDAConstant final : public ParsedAttrInfo { |
| 1744 | ParsedAttrInfoCUDAConstant() { |
| 1745 | AttrKind = ParsedAttr::AT_CUDAConstant; |
| 1746 | NumArgs = 0; |
| 1747 | OptArgs = 0; |
| 1748 | HasCustomParsing = 0; |
| 1749 | IsTargetSpecific = 0; |
| 1750 | IsType = 0; |
| 1751 | IsStmt = 0; |
| 1752 | IsKnownToGCC = 0; |
| 1753 | IsSupportedByPragmaAttribute = 1; |
| 1754 | Spellings = CUDAConstantSpellings; |
| 1755 | } |
| 1756 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1757 | if (!isa<VarDecl>(D)) { |
| 1758 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1759 | << Attr << "variables" ; |
| 1760 | return false; |
| 1761 | } |
| 1762 | return true; |
| 1763 | } |
| 1764 | |
| 1765 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 1766 | auto &LangOpts = S.LangOpts; |
| 1767 | if (LangOpts.CUDA) |
| 1768 | return true; |
| 1769 | |
| 1770 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 1771 | return false; |
| 1772 | } |
| 1773 | |
| 1774 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1775 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 1776 | } |
| 1777 | |
| 1778 | static const ParsedAttrInfoCUDAConstant Instance; |
| 1779 | }; |
| 1780 | const ParsedAttrInfoCUDAConstant ParsedAttrInfoCUDAConstant::Instance; |
| 1781 | static constexpr ParsedAttrInfo::Spelling CUDADeviceSpellings[] = { |
| 1782 | {AttributeCommonInfo::AS_GNU, "device" }, |
| 1783 | {AttributeCommonInfo::AS_Declspec, "__device__" }, |
| 1784 | }; |
| 1785 | struct ParsedAttrInfoCUDADevice final : public ParsedAttrInfo { |
| 1786 | ParsedAttrInfoCUDADevice() { |
| 1787 | AttrKind = ParsedAttr::AT_CUDADevice; |
| 1788 | NumArgs = 0; |
| 1789 | OptArgs = 0; |
| 1790 | HasCustomParsing = 0; |
| 1791 | IsTargetSpecific = 0; |
| 1792 | IsType = 0; |
| 1793 | IsStmt = 0; |
| 1794 | IsKnownToGCC = 0; |
| 1795 | IsSupportedByPragmaAttribute = 1; |
| 1796 | Spellings = CUDADeviceSpellings; |
| 1797 | } |
| 1798 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1799 | if (!isa<FunctionDecl>(D) && !isa<VarDecl>(D)) { |
| 1800 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1801 | << Attr << "functions and variables" ; |
| 1802 | return false; |
| 1803 | } |
| 1804 | return true; |
| 1805 | } |
| 1806 | |
| 1807 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 1808 | auto &LangOpts = S.LangOpts; |
| 1809 | if (LangOpts.CUDA) |
| 1810 | return true; |
| 1811 | |
| 1812 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 1813 | return false; |
| 1814 | } |
| 1815 | |
| 1816 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1817 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1818 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 1819 | } |
| 1820 | |
| 1821 | static const ParsedAttrInfoCUDADevice Instance; |
| 1822 | }; |
| 1823 | const ParsedAttrInfoCUDADevice ParsedAttrInfoCUDADevice::Instance; |
| 1824 | static constexpr ParsedAttrInfo::Spelling CUDADeviceBuiltinSurfaceTypeSpellings[] = { |
| 1825 | {AttributeCommonInfo::AS_GNU, "device_builtin_surface_type" }, |
| 1826 | {AttributeCommonInfo::AS_Declspec, "__device_builtin_surface_type__" }, |
| 1827 | }; |
| 1828 | struct ParsedAttrInfoCUDADeviceBuiltinSurfaceType final : public ParsedAttrInfo { |
| 1829 | ParsedAttrInfoCUDADeviceBuiltinSurfaceType() { |
| 1830 | AttrKind = ParsedAttr::AT_CUDADeviceBuiltinSurfaceType; |
| 1831 | NumArgs = 0; |
| 1832 | OptArgs = 0; |
| 1833 | HasCustomParsing = 0; |
| 1834 | IsTargetSpecific = 0; |
| 1835 | IsType = 0; |
| 1836 | IsStmt = 0; |
| 1837 | IsKnownToGCC = 0; |
| 1838 | IsSupportedByPragmaAttribute = 1; |
| 1839 | Spellings = CUDADeviceBuiltinSurfaceTypeSpellings; |
| 1840 | } |
| 1841 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1842 | if (!isa<CXXRecordDecl>(D)) { |
| 1843 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1844 | << Attr << "classes" ; |
| 1845 | return false; |
| 1846 | } |
| 1847 | return true; |
| 1848 | } |
| 1849 | |
| 1850 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 1851 | auto &LangOpts = S.LangOpts; |
| 1852 | if (LangOpts.CUDA) |
| 1853 | return true; |
| 1854 | |
| 1855 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 1856 | return false; |
| 1857 | } |
| 1858 | |
| 1859 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1860 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 1861 | } |
| 1862 | |
| 1863 | static const ParsedAttrInfoCUDADeviceBuiltinSurfaceType Instance; |
| 1864 | }; |
| 1865 | const ParsedAttrInfoCUDADeviceBuiltinSurfaceType ParsedAttrInfoCUDADeviceBuiltinSurfaceType::Instance; |
| 1866 | static constexpr ParsedAttrInfo::Spelling CUDADeviceBuiltinTextureTypeSpellings[] = { |
| 1867 | {AttributeCommonInfo::AS_GNU, "device_builtin_texture_type" }, |
| 1868 | {AttributeCommonInfo::AS_Declspec, "__device_builtin_texture_type__" }, |
| 1869 | }; |
| 1870 | struct ParsedAttrInfoCUDADeviceBuiltinTextureType final : public ParsedAttrInfo { |
| 1871 | ParsedAttrInfoCUDADeviceBuiltinTextureType() { |
| 1872 | AttrKind = ParsedAttr::AT_CUDADeviceBuiltinTextureType; |
| 1873 | NumArgs = 0; |
| 1874 | OptArgs = 0; |
| 1875 | HasCustomParsing = 0; |
| 1876 | IsTargetSpecific = 0; |
| 1877 | IsType = 0; |
| 1878 | IsStmt = 0; |
| 1879 | IsKnownToGCC = 0; |
| 1880 | IsSupportedByPragmaAttribute = 1; |
| 1881 | Spellings = CUDADeviceBuiltinTextureTypeSpellings; |
| 1882 | } |
| 1883 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1884 | if (!isa<CXXRecordDecl>(D)) { |
| 1885 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1886 | << Attr << "classes" ; |
| 1887 | return false; |
| 1888 | } |
| 1889 | return true; |
| 1890 | } |
| 1891 | |
| 1892 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 1893 | auto &LangOpts = S.LangOpts; |
| 1894 | if (LangOpts.CUDA) |
| 1895 | return true; |
| 1896 | |
| 1897 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 1898 | return false; |
| 1899 | } |
| 1900 | |
| 1901 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1902 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 1903 | } |
| 1904 | |
| 1905 | static const ParsedAttrInfoCUDADeviceBuiltinTextureType Instance; |
| 1906 | }; |
| 1907 | const ParsedAttrInfoCUDADeviceBuiltinTextureType ParsedAttrInfoCUDADeviceBuiltinTextureType::Instance; |
| 1908 | static constexpr ParsedAttrInfo::Spelling CUDAGlobalSpellings[] = { |
| 1909 | {AttributeCommonInfo::AS_GNU, "global" }, |
| 1910 | {AttributeCommonInfo::AS_Declspec, "__global__" }, |
| 1911 | }; |
| 1912 | struct ParsedAttrInfoCUDAGlobal final : public ParsedAttrInfo { |
| 1913 | ParsedAttrInfoCUDAGlobal() { |
| 1914 | AttrKind = ParsedAttr::AT_CUDAGlobal; |
| 1915 | NumArgs = 0; |
| 1916 | OptArgs = 0; |
| 1917 | HasCustomParsing = 0; |
| 1918 | IsTargetSpecific = 0; |
| 1919 | IsType = 0; |
| 1920 | IsStmt = 0; |
| 1921 | IsKnownToGCC = 0; |
| 1922 | IsSupportedByPragmaAttribute = 1; |
| 1923 | Spellings = CUDAGlobalSpellings; |
| 1924 | } |
| 1925 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1926 | if (!isa<FunctionDecl>(D)) { |
| 1927 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1928 | << Attr << "functions" ; |
| 1929 | return false; |
| 1930 | } |
| 1931 | return true; |
| 1932 | } |
| 1933 | |
| 1934 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 1935 | auto &LangOpts = S.LangOpts; |
| 1936 | if (LangOpts.CUDA) |
| 1937 | return true; |
| 1938 | |
| 1939 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 1940 | return false; |
| 1941 | } |
| 1942 | |
| 1943 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1944 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1945 | } |
| 1946 | |
| 1947 | static const ParsedAttrInfoCUDAGlobal Instance; |
| 1948 | }; |
| 1949 | const ParsedAttrInfoCUDAGlobal ParsedAttrInfoCUDAGlobal::Instance; |
| 1950 | static constexpr ParsedAttrInfo::Spelling CUDAHostSpellings[] = { |
| 1951 | {AttributeCommonInfo::AS_GNU, "host" }, |
| 1952 | {AttributeCommonInfo::AS_Declspec, "__host__" }, |
| 1953 | }; |
| 1954 | struct ParsedAttrInfoCUDAHost final : public ParsedAttrInfo { |
| 1955 | ParsedAttrInfoCUDAHost() { |
| 1956 | AttrKind = ParsedAttr::AT_CUDAHost; |
| 1957 | NumArgs = 0; |
| 1958 | OptArgs = 0; |
| 1959 | HasCustomParsing = 0; |
| 1960 | IsTargetSpecific = 0; |
| 1961 | IsType = 0; |
| 1962 | IsStmt = 0; |
| 1963 | IsKnownToGCC = 0; |
| 1964 | IsSupportedByPragmaAttribute = 1; |
| 1965 | Spellings = CUDAHostSpellings; |
| 1966 | } |
| 1967 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 1968 | if (!isa<FunctionDecl>(D)) { |
| 1969 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 1970 | << Attr << "functions" ; |
| 1971 | return false; |
| 1972 | } |
| 1973 | return true; |
| 1974 | } |
| 1975 | |
| 1976 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 1977 | auto &LangOpts = S.LangOpts; |
| 1978 | if (LangOpts.CUDA) |
| 1979 | return true; |
| 1980 | |
| 1981 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 1982 | return false; |
| 1983 | } |
| 1984 | |
| 1985 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 1986 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 1987 | } |
| 1988 | |
| 1989 | static const ParsedAttrInfoCUDAHost Instance; |
| 1990 | }; |
| 1991 | const ParsedAttrInfoCUDAHost ParsedAttrInfoCUDAHost::Instance; |
| 1992 | struct ParsedAttrInfoCUDAInvalidTarget final : public ParsedAttrInfo { |
| 1993 | ParsedAttrInfoCUDAInvalidTarget() { |
| 1994 | AttrKind = ParsedAttr::AT_CUDAInvalidTarget; |
| 1995 | NumArgs = 0; |
| 1996 | OptArgs = 0; |
| 1997 | HasCustomParsing = 0; |
| 1998 | IsTargetSpecific = 0; |
| 1999 | IsType = 0; |
| 2000 | IsStmt = 0; |
| 2001 | IsKnownToGCC = 0; |
| 2002 | IsSupportedByPragmaAttribute = 0; |
| 2003 | } |
| 2004 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2005 | if (!isa<FunctionDecl>(D)) { |
| 2006 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2007 | << Attr << "functions" ; |
| 2008 | return false; |
| 2009 | } |
| 2010 | return true; |
| 2011 | } |
| 2012 | |
| 2013 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 2014 | auto &LangOpts = S.LangOpts; |
| 2015 | if (LangOpts.CUDA) |
| 2016 | return true; |
| 2017 | |
| 2018 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 2019 | return false; |
| 2020 | } |
| 2021 | |
| 2022 | static const ParsedAttrInfoCUDAInvalidTarget Instance; |
| 2023 | }; |
| 2024 | const ParsedAttrInfoCUDAInvalidTarget ParsedAttrInfoCUDAInvalidTarget::Instance; |
| 2025 | static constexpr ParsedAttrInfo::Spelling CUDALaunchBoundsSpellings[] = { |
| 2026 | {AttributeCommonInfo::AS_GNU, "launch_bounds" }, |
| 2027 | {AttributeCommonInfo::AS_Declspec, "__launch_bounds__" }, |
| 2028 | }; |
| 2029 | struct ParsedAttrInfoCUDALaunchBounds final : public ParsedAttrInfo { |
| 2030 | ParsedAttrInfoCUDALaunchBounds() { |
| 2031 | AttrKind = ParsedAttr::AT_CUDALaunchBounds; |
| 2032 | NumArgs = 1; |
| 2033 | OptArgs = 1; |
| 2034 | HasCustomParsing = 0; |
| 2035 | IsTargetSpecific = 0; |
| 2036 | IsType = 0; |
| 2037 | IsStmt = 0; |
| 2038 | IsKnownToGCC = 0; |
| 2039 | IsSupportedByPragmaAttribute = 1; |
| 2040 | Spellings = CUDALaunchBoundsSpellings; |
| 2041 | } |
| 2042 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2043 | if (!isa<ObjCMethodDecl>(D) && !isFunctionLike(D)) { |
| 2044 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2045 | << Attr << "Objective-C methods, functions, and function pointers" ; |
| 2046 | return false; |
| 2047 | } |
| 2048 | return true; |
| 2049 | } |
| 2050 | |
| 2051 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 2052 | auto &LangOpts = S.LangOpts; |
| 2053 | if (LangOpts.CUDA) |
| 2054 | return true; |
| 2055 | |
| 2056 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 2057 | return false; |
| 2058 | } |
| 2059 | |
| 2060 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2061 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 2062 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
| 2063 | } |
| 2064 | |
| 2065 | static const ParsedAttrInfoCUDALaunchBounds Instance; |
| 2066 | }; |
| 2067 | const ParsedAttrInfoCUDALaunchBounds ParsedAttrInfoCUDALaunchBounds::Instance; |
| 2068 | static constexpr ParsedAttrInfo::Spelling CUDASharedSpellings[] = { |
| 2069 | {AttributeCommonInfo::AS_GNU, "shared" }, |
| 2070 | {AttributeCommonInfo::AS_Declspec, "__shared__" }, |
| 2071 | }; |
| 2072 | struct ParsedAttrInfoCUDAShared final : public ParsedAttrInfo { |
| 2073 | ParsedAttrInfoCUDAShared() { |
| 2074 | AttrKind = ParsedAttr::AT_CUDAShared; |
| 2075 | NumArgs = 0; |
| 2076 | OptArgs = 0; |
| 2077 | HasCustomParsing = 0; |
| 2078 | IsTargetSpecific = 0; |
| 2079 | IsType = 0; |
| 2080 | IsStmt = 0; |
| 2081 | IsKnownToGCC = 0; |
| 2082 | IsSupportedByPragmaAttribute = 1; |
| 2083 | Spellings = CUDASharedSpellings; |
| 2084 | } |
| 2085 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2086 | if (!isa<VarDecl>(D)) { |
| 2087 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2088 | << Attr << "variables" ; |
| 2089 | return false; |
| 2090 | } |
| 2091 | return true; |
| 2092 | } |
| 2093 | |
| 2094 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 2095 | auto &LangOpts = S.LangOpts; |
| 2096 | if (LangOpts.CUDA) |
| 2097 | return true; |
| 2098 | |
| 2099 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 2100 | return false; |
| 2101 | } |
| 2102 | |
| 2103 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2104 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 2105 | } |
| 2106 | |
| 2107 | static const ParsedAttrInfoCUDAShared Instance; |
| 2108 | }; |
| 2109 | const ParsedAttrInfoCUDAShared ParsedAttrInfoCUDAShared::Instance; |
| 2110 | static constexpr ParsedAttrInfo::Spelling CXX11NoReturnSpellings[] = { |
| 2111 | {AttributeCommonInfo::AS_CXX11, "noreturn" }, |
| 2112 | }; |
| 2113 | struct ParsedAttrInfoCXX11NoReturn final : public ParsedAttrInfo { |
| 2114 | ParsedAttrInfoCXX11NoReturn() { |
| 2115 | AttrKind = ParsedAttr::AT_CXX11NoReturn; |
| 2116 | NumArgs = 0; |
| 2117 | OptArgs = 0; |
| 2118 | HasCustomParsing = 0; |
| 2119 | IsTargetSpecific = 0; |
| 2120 | IsType = 0; |
| 2121 | IsStmt = 0; |
| 2122 | IsKnownToGCC = 0; |
| 2123 | IsSupportedByPragmaAttribute = 1; |
| 2124 | Spellings = CXX11NoReturnSpellings; |
| 2125 | } |
| 2126 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2127 | if (!isa<FunctionDecl>(D)) { |
| 2128 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 2129 | << Attr << "functions" ; |
| 2130 | return false; |
| 2131 | } |
| 2132 | return true; |
| 2133 | } |
| 2134 | |
| 2135 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2136 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 2137 | } |
| 2138 | |
| 2139 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 2140 | D->addAttr(::new (S.Context) CXX11NoReturnAttr(S.Context, Attr)); |
| 2141 | return AttributeApplied; |
| 2142 | } |
| 2143 | |
| 2144 | static const ParsedAttrInfoCXX11NoReturn Instance; |
| 2145 | }; |
| 2146 | const ParsedAttrInfoCXX11NoReturn ParsedAttrInfoCXX11NoReturn::Instance; |
| 2147 | static constexpr ParsedAttrInfo::Spelling CallableWhenSpellings[] = { |
| 2148 | {AttributeCommonInfo::AS_GNU, "callable_when" }, |
| 2149 | {AttributeCommonInfo::AS_CXX11, "clang::callable_when" }, |
| 2150 | }; |
| 2151 | struct ParsedAttrInfoCallableWhen final : public ParsedAttrInfo { |
| 2152 | ParsedAttrInfoCallableWhen() { |
| 2153 | AttrKind = ParsedAttr::AT_CallableWhen; |
| 2154 | NumArgs = 0; |
| 2155 | OptArgs = 15; |
| 2156 | HasCustomParsing = 0; |
| 2157 | IsTargetSpecific = 0; |
| 2158 | IsType = 0; |
| 2159 | IsStmt = 0; |
| 2160 | IsKnownToGCC = 0; |
| 2161 | IsSupportedByPragmaAttribute = 1; |
| 2162 | Spellings = CallableWhenSpellings; |
| 2163 | } |
| 2164 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2165 | if (!isa<CXXMethodDecl>(D)) { |
| 2166 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2167 | << Attr << "functions" ; |
| 2168 | return false; |
| 2169 | } |
| 2170 | return true; |
| 2171 | } |
| 2172 | |
| 2173 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2174 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function_is_member, /*IsSupported=*/LangOpts.CPlusPlus)); |
| 2175 | } |
| 2176 | |
| 2177 | static const ParsedAttrInfoCallableWhen Instance; |
| 2178 | }; |
| 2179 | const ParsedAttrInfoCallableWhen ParsedAttrInfoCallableWhen::Instance; |
| 2180 | static constexpr ParsedAttrInfo::Spelling CallbackSpellings[] = { |
| 2181 | {AttributeCommonInfo::AS_GNU, "callback" }, |
| 2182 | {AttributeCommonInfo::AS_CXX11, "clang::callback" }, |
| 2183 | {AttributeCommonInfo::AS_C2x, "clang::callback" }, |
| 2184 | }; |
| 2185 | struct ParsedAttrInfoCallback final : public ParsedAttrInfo { |
| 2186 | ParsedAttrInfoCallback() { |
| 2187 | AttrKind = ParsedAttr::AT_Callback; |
| 2188 | NumArgs = 0; |
| 2189 | OptArgs = 15; |
| 2190 | HasCustomParsing = 0; |
| 2191 | IsTargetSpecific = 0; |
| 2192 | IsType = 0; |
| 2193 | IsStmt = 0; |
| 2194 | IsKnownToGCC = 0; |
| 2195 | IsSupportedByPragmaAttribute = 1; |
| 2196 | Spellings = CallbackSpellings; |
| 2197 | } |
| 2198 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2199 | if (!isa<FunctionDecl>(D)) { |
| 2200 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2201 | << Attr << "functions" ; |
| 2202 | return false; |
| 2203 | } |
| 2204 | return true; |
| 2205 | } |
| 2206 | |
| 2207 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2208 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 2209 | } |
| 2210 | |
| 2211 | static const ParsedAttrInfoCallback Instance; |
| 2212 | }; |
| 2213 | const ParsedAttrInfoCallback ParsedAttrInfoCallback::Instance; |
| 2214 | static constexpr ParsedAttrInfo::Spelling CalledOnceSpellings[] = { |
| 2215 | {AttributeCommonInfo::AS_GNU, "called_once" }, |
| 2216 | {AttributeCommonInfo::AS_CXX11, "clang::called_once" }, |
| 2217 | {AttributeCommonInfo::AS_C2x, "clang::called_once" }, |
| 2218 | }; |
| 2219 | struct ParsedAttrInfoCalledOnce final : public ParsedAttrInfo { |
| 2220 | ParsedAttrInfoCalledOnce() { |
| 2221 | AttrKind = ParsedAttr::AT_CalledOnce; |
| 2222 | NumArgs = 0; |
| 2223 | OptArgs = 0; |
| 2224 | HasCustomParsing = 0; |
| 2225 | IsTargetSpecific = 0; |
| 2226 | IsType = 0; |
| 2227 | IsStmt = 0; |
| 2228 | IsKnownToGCC = 0; |
| 2229 | IsSupportedByPragmaAttribute = 1; |
| 2230 | Spellings = CalledOnceSpellings; |
| 2231 | } |
| 2232 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2233 | if (!isa<ParmVarDecl>(D)) { |
| 2234 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2235 | << Attr << "parameters" ; |
| 2236 | return false; |
| 2237 | } |
| 2238 | return true; |
| 2239 | } |
| 2240 | |
| 2241 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 2242 | auto &LangOpts = S.LangOpts; |
| 2243 | if (LangOpts.ObjC) |
| 2244 | return true; |
| 2245 | |
| 2246 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 2247 | return false; |
| 2248 | } |
| 2249 | |
| 2250 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2251 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 2252 | } |
| 2253 | |
| 2254 | static const ParsedAttrInfoCalledOnce Instance; |
| 2255 | }; |
| 2256 | const ParsedAttrInfoCalledOnce ParsedAttrInfoCalledOnce::Instance; |
| 2257 | static constexpr ParsedAttrInfo::Spelling CapabilitySpellings[] = { |
| 2258 | {AttributeCommonInfo::AS_GNU, "capability" }, |
| 2259 | {AttributeCommonInfo::AS_CXX11, "clang::capability" }, |
| 2260 | {AttributeCommonInfo::AS_GNU, "shared_capability" }, |
| 2261 | {AttributeCommonInfo::AS_CXX11, "clang::shared_capability" }, |
| 2262 | }; |
| 2263 | struct ParsedAttrInfoCapability final : public ParsedAttrInfo { |
| 2264 | ParsedAttrInfoCapability() { |
| 2265 | AttrKind = ParsedAttr::AT_Capability; |
| 2266 | NumArgs = 1; |
| 2267 | OptArgs = 0; |
| 2268 | HasCustomParsing = 0; |
| 2269 | IsTargetSpecific = 0; |
| 2270 | IsType = 0; |
| 2271 | IsStmt = 0; |
| 2272 | IsKnownToGCC = 0; |
| 2273 | IsSupportedByPragmaAttribute = 1; |
| 2274 | Spellings = CapabilitySpellings; |
| 2275 | } |
| 2276 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2277 | if (!isa<RecordDecl>(D) && !isa<TypedefNameDecl>(D)) { |
| 2278 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 2279 | << Attr << "structs, unions, classes, and typedefs" ; |
| 2280 | return false; |
| 2281 | } |
| 2282 | return true; |
| 2283 | } |
| 2284 | |
| 2285 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 2286 | enum Spelling { |
| 2287 | GNU_capability = 0, |
| 2288 | CXX11_clang_capability = 1, |
| 2289 | GNU_shared_capability = 2, |
| 2290 | CXX11_clang_shared_capability = 3, |
| 2291 | SpellingNotCalculated = 15 |
| 2292 | |
| 2293 | }; |
| 2294 | |
| 2295 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 2296 | switch (Idx) { |
| 2297 | default: llvm_unreachable("Unknown spelling list index" ); |
| 2298 | case 0: return GNU_capability; |
| 2299 | case 1: return CXX11_clang_capability; |
| 2300 | case 2: return GNU_shared_capability; |
| 2301 | case 3: return CXX11_clang_shared_capability; |
| 2302 | } |
| 2303 | } |
| 2304 | |
| 2305 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2306 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 2307 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
| 2308 | } |
| 2309 | |
| 2310 | static const ParsedAttrInfoCapability Instance; |
| 2311 | }; |
| 2312 | const ParsedAttrInfoCapability ParsedAttrInfoCapability::Instance; |
| 2313 | static constexpr ParsedAttrInfo::Spelling CarriesDependencySpellings[] = { |
| 2314 | {AttributeCommonInfo::AS_GNU, "carries_dependency" }, |
| 2315 | {AttributeCommonInfo::AS_CXX11, "carries_dependency" }, |
| 2316 | }; |
| 2317 | struct ParsedAttrInfoCarriesDependency final : public ParsedAttrInfo { |
| 2318 | ParsedAttrInfoCarriesDependency() { |
| 2319 | AttrKind = ParsedAttr::AT_CarriesDependency; |
| 2320 | NumArgs = 0; |
| 2321 | OptArgs = 0; |
| 2322 | HasCustomParsing = 0; |
| 2323 | IsTargetSpecific = 0; |
| 2324 | IsType = 0; |
| 2325 | IsStmt = 0; |
| 2326 | IsKnownToGCC = 0; |
| 2327 | IsSupportedByPragmaAttribute = 1; |
| 2328 | Spellings = CarriesDependencySpellings; |
| 2329 | } |
| 2330 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2331 | if (!isa<ParmVarDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<FunctionDecl>(D)) { |
| 2332 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 2333 | << Attr << "parameters, Objective-C methods, and functions" ; |
| 2334 | return false; |
| 2335 | } |
| 2336 | return true; |
| 2337 | } |
| 2338 | |
| 2339 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2340 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 2341 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 2342 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 2343 | } |
| 2344 | |
| 2345 | static const ParsedAttrInfoCarriesDependency Instance; |
| 2346 | }; |
| 2347 | const ParsedAttrInfoCarriesDependency ParsedAttrInfoCarriesDependency::Instance; |
| 2348 | static constexpr ParsedAttrInfo::Spelling CleanupSpellings[] = { |
| 2349 | {AttributeCommonInfo::AS_GNU, "cleanup" }, |
| 2350 | {AttributeCommonInfo::AS_CXX11, "gnu::cleanup" }, |
| 2351 | {AttributeCommonInfo::AS_C2x, "gnu::cleanup" }, |
| 2352 | }; |
| 2353 | struct ParsedAttrInfoCleanup final : public ParsedAttrInfo { |
| 2354 | ParsedAttrInfoCleanup() { |
| 2355 | AttrKind = ParsedAttr::AT_Cleanup; |
| 2356 | NumArgs = 1; |
| 2357 | OptArgs = 0; |
| 2358 | HasCustomParsing = 0; |
| 2359 | IsTargetSpecific = 0; |
| 2360 | IsType = 0; |
| 2361 | IsStmt = 0; |
| 2362 | IsKnownToGCC = 1; |
| 2363 | IsSupportedByPragmaAttribute = 1; |
| 2364 | Spellings = CleanupSpellings; |
| 2365 | } |
| 2366 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2367 | if (!isLocalVar(D)) { |
| 2368 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2369 | << Attr << "local variables" ; |
| 2370 | return false; |
| 2371 | } |
| 2372 | return true; |
| 2373 | } |
| 2374 | |
| 2375 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2376 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_local, /*IsSupported=*/true)); |
| 2377 | } |
| 2378 | |
| 2379 | static const ParsedAttrInfoCleanup Instance; |
| 2380 | }; |
| 2381 | const ParsedAttrInfoCleanup ParsedAttrInfoCleanup::Instance; |
| 2382 | static constexpr ParsedAttrInfo::Spelling CmseNSCallSpellings[] = { |
| 2383 | {AttributeCommonInfo::AS_GNU, "cmse_nonsecure_call" }, |
| 2384 | }; |
| 2385 | struct ParsedAttrInfoCmseNSCall final : public ParsedAttrInfo { |
| 2386 | ParsedAttrInfoCmseNSCall() { |
| 2387 | AttrKind = ParsedAttr::AT_CmseNSCall; |
| 2388 | NumArgs = 0; |
| 2389 | OptArgs = 0; |
| 2390 | HasCustomParsing = 0; |
| 2391 | IsTargetSpecific = 1; |
| 2392 | IsType = 1; |
| 2393 | IsStmt = 0; |
| 2394 | IsKnownToGCC = 0; |
| 2395 | IsSupportedByPragmaAttribute = 0; |
| 2396 | Spellings = CmseNSCallSpellings; |
| 2397 | } |
| 2398 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 2399 | auto &LangOpts = S.LangOpts; |
| 2400 | if (LangOpts.Cmse) |
| 2401 | return true; |
| 2402 | |
| 2403 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 2404 | return false; |
| 2405 | } |
| 2406 | |
| 2407 | bool existsInTarget(const TargetInfo &Target) const override { |
| 2408 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 2409 | return true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb); |
| 2410 | } |
| 2411 | |
| 2412 | static const ParsedAttrInfoCmseNSCall Instance; |
| 2413 | }; |
| 2414 | const ParsedAttrInfoCmseNSCall ParsedAttrInfoCmseNSCall::Instance; |
| 2415 | static constexpr ParsedAttrInfo::Spelling CmseNSEntrySpellings[] = { |
| 2416 | {AttributeCommonInfo::AS_GNU, "cmse_nonsecure_entry" }, |
| 2417 | }; |
| 2418 | struct ParsedAttrInfoCmseNSEntry final : public ParsedAttrInfo { |
| 2419 | ParsedAttrInfoCmseNSEntry() { |
| 2420 | AttrKind = ParsedAttr::AT_CmseNSEntry; |
| 2421 | NumArgs = 0; |
| 2422 | OptArgs = 0; |
| 2423 | HasCustomParsing = 0; |
| 2424 | IsTargetSpecific = 1; |
| 2425 | IsType = 0; |
| 2426 | IsStmt = 0; |
| 2427 | IsKnownToGCC = 0; |
| 2428 | IsSupportedByPragmaAttribute = 1; |
| 2429 | Spellings = CmseNSEntrySpellings; |
| 2430 | } |
| 2431 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2432 | if (!isa<FunctionDecl>(D)) { |
| 2433 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2434 | << Attr << "functions" ; |
| 2435 | return false; |
| 2436 | } |
| 2437 | return true; |
| 2438 | } |
| 2439 | |
| 2440 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 2441 | auto &LangOpts = S.LangOpts; |
| 2442 | if (LangOpts.Cmse) |
| 2443 | return true; |
| 2444 | |
| 2445 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 2446 | return false; |
| 2447 | } |
| 2448 | |
| 2449 | bool existsInTarget(const TargetInfo &Target) const override { |
| 2450 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 2451 | return true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb); |
| 2452 | } |
| 2453 | |
| 2454 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2455 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 2456 | } |
| 2457 | |
| 2458 | static const ParsedAttrInfoCmseNSEntry Instance; |
| 2459 | }; |
| 2460 | const ParsedAttrInfoCmseNSEntry ParsedAttrInfoCmseNSEntry::Instance; |
| 2461 | static constexpr ParsedAttrInfo::Spelling CodeSegSpellings[] = { |
| 2462 | {AttributeCommonInfo::AS_Declspec, "code_seg" }, |
| 2463 | }; |
| 2464 | struct ParsedAttrInfoCodeSeg final : public ParsedAttrInfo { |
| 2465 | ParsedAttrInfoCodeSeg() { |
| 2466 | AttrKind = ParsedAttr::AT_CodeSeg; |
| 2467 | NumArgs = 1; |
| 2468 | OptArgs = 0; |
| 2469 | HasCustomParsing = 0; |
| 2470 | IsTargetSpecific = 0; |
| 2471 | IsType = 0; |
| 2472 | IsStmt = 0; |
| 2473 | IsKnownToGCC = 0; |
| 2474 | IsSupportedByPragmaAttribute = 0; |
| 2475 | Spellings = CodeSegSpellings; |
| 2476 | } |
| 2477 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2478 | if (!isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D)) { |
| 2479 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 2480 | << Attr << "functions and classes" ; |
| 2481 | return false; |
| 2482 | } |
| 2483 | return true; |
| 2484 | } |
| 2485 | |
| 2486 | static const ParsedAttrInfoCodeSeg Instance; |
| 2487 | }; |
| 2488 | const ParsedAttrInfoCodeSeg ParsedAttrInfoCodeSeg::Instance; |
| 2489 | static constexpr ParsedAttrInfo::Spelling ColdSpellings[] = { |
| 2490 | {AttributeCommonInfo::AS_GNU, "cold" }, |
| 2491 | {AttributeCommonInfo::AS_CXX11, "gnu::cold" }, |
| 2492 | {AttributeCommonInfo::AS_C2x, "gnu::cold" }, |
| 2493 | }; |
| 2494 | struct ParsedAttrInfoCold final : public ParsedAttrInfo { |
| 2495 | ParsedAttrInfoCold() { |
| 2496 | AttrKind = ParsedAttr::AT_Cold; |
| 2497 | NumArgs = 0; |
| 2498 | OptArgs = 0; |
| 2499 | HasCustomParsing = 0; |
| 2500 | IsTargetSpecific = 0; |
| 2501 | IsType = 0; |
| 2502 | IsStmt = 0; |
| 2503 | IsKnownToGCC = 1; |
| 2504 | IsSupportedByPragmaAttribute = 1; |
| 2505 | Spellings = ColdSpellings; |
| 2506 | } |
| 2507 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2508 | if (!isa<FunctionDecl>(D)) { |
| 2509 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2510 | << Attr << "functions" ; |
| 2511 | return false; |
| 2512 | } |
| 2513 | return true; |
| 2514 | } |
| 2515 | |
| 2516 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2517 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 2518 | } |
| 2519 | |
| 2520 | static const ParsedAttrInfoCold Instance; |
| 2521 | }; |
| 2522 | const ParsedAttrInfoCold ParsedAttrInfoCold::Instance; |
| 2523 | static constexpr ParsedAttrInfo::Spelling CommonSpellings[] = { |
| 2524 | {AttributeCommonInfo::AS_GNU, "common" }, |
| 2525 | {AttributeCommonInfo::AS_CXX11, "gnu::common" }, |
| 2526 | {AttributeCommonInfo::AS_C2x, "gnu::common" }, |
| 2527 | }; |
| 2528 | struct ParsedAttrInfoCommon final : public ParsedAttrInfo { |
| 2529 | ParsedAttrInfoCommon() { |
| 2530 | AttrKind = ParsedAttr::AT_Common; |
| 2531 | NumArgs = 0; |
| 2532 | OptArgs = 0; |
| 2533 | HasCustomParsing = 0; |
| 2534 | IsTargetSpecific = 0; |
| 2535 | IsType = 0; |
| 2536 | IsStmt = 0; |
| 2537 | IsKnownToGCC = 1; |
| 2538 | IsSupportedByPragmaAttribute = 1; |
| 2539 | Spellings = CommonSpellings; |
| 2540 | } |
| 2541 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2542 | if (!isa<VarDecl>(D)) { |
| 2543 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2544 | << Attr << "variables" ; |
| 2545 | return false; |
| 2546 | } |
| 2547 | return true; |
| 2548 | } |
| 2549 | |
| 2550 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2551 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 2552 | } |
| 2553 | |
| 2554 | static const ParsedAttrInfoCommon Instance; |
| 2555 | }; |
| 2556 | const ParsedAttrInfoCommon ParsedAttrInfoCommon::Instance; |
| 2557 | static constexpr ParsedAttrInfo::Spelling ConstSpellings[] = { |
| 2558 | {AttributeCommonInfo::AS_GNU, "const" }, |
| 2559 | {AttributeCommonInfo::AS_CXX11, "gnu::const" }, |
| 2560 | {AttributeCommonInfo::AS_C2x, "gnu::const" }, |
| 2561 | {AttributeCommonInfo::AS_GNU, "__const" }, |
| 2562 | {AttributeCommonInfo::AS_CXX11, "gnu::__const" }, |
| 2563 | {AttributeCommonInfo::AS_C2x, "gnu::__const" }, |
| 2564 | }; |
| 2565 | struct ParsedAttrInfoConst final : public ParsedAttrInfo { |
| 2566 | ParsedAttrInfoConst() { |
| 2567 | AttrKind = ParsedAttr::AT_Const; |
| 2568 | NumArgs = 0; |
| 2569 | OptArgs = 0; |
| 2570 | HasCustomParsing = 0; |
| 2571 | IsTargetSpecific = 0; |
| 2572 | IsType = 0; |
| 2573 | IsStmt = 0; |
| 2574 | IsKnownToGCC = 1; |
| 2575 | IsSupportedByPragmaAttribute = 0; |
| 2576 | Spellings = ConstSpellings; |
| 2577 | } |
| 2578 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 2579 | D->addAttr(::new (S.Context) ConstAttr(S.Context, Attr)); |
| 2580 | return AttributeApplied; |
| 2581 | } |
| 2582 | |
| 2583 | static const ParsedAttrInfoConst Instance; |
| 2584 | }; |
| 2585 | const ParsedAttrInfoConst ParsedAttrInfoConst::Instance; |
| 2586 | static constexpr ParsedAttrInfo::Spelling ConstInitSpellings[] = { |
| 2587 | {AttributeCommonInfo::AS_Keyword, "constinit" }, |
| 2588 | {AttributeCommonInfo::AS_GNU, "require_constant_initialization" }, |
| 2589 | {AttributeCommonInfo::AS_CXX11, "clang::require_constant_initialization" }, |
| 2590 | }; |
| 2591 | struct ParsedAttrInfoConstInit final : public ParsedAttrInfo { |
| 2592 | ParsedAttrInfoConstInit() { |
| 2593 | AttrKind = ParsedAttr::AT_ConstInit; |
| 2594 | NumArgs = 0; |
| 2595 | OptArgs = 0; |
| 2596 | HasCustomParsing = 0; |
| 2597 | IsTargetSpecific = 0; |
| 2598 | IsType = 0; |
| 2599 | IsStmt = 0; |
| 2600 | IsKnownToGCC = 0; |
| 2601 | IsSupportedByPragmaAttribute = 1; |
| 2602 | Spellings = ConstInitSpellings; |
| 2603 | } |
| 2604 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2605 | if (!isGlobalVar(D)) { |
| 2606 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 2607 | << Attr << "global variables" ; |
| 2608 | return false; |
| 2609 | } |
| 2610 | return true; |
| 2611 | } |
| 2612 | |
| 2613 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 2614 | auto &LangOpts = S.LangOpts; |
| 2615 | if (LangOpts.CPlusPlus) |
| 2616 | return true; |
| 2617 | |
| 2618 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 2619 | return false; |
| 2620 | } |
| 2621 | |
| 2622 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 2623 | enum Spelling { |
| 2624 | Keyword_constinit = 0, |
| 2625 | GNU_require_constant_initialization = 1, |
| 2626 | CXX11_clang_require_constant_initialization = 2, |
| 2627 | SpellingNotCalculated = 15 |
| 2628 | |
| 2629 | }; |
| 2630 | |
| 2631 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 2632 | switch (Idx) { |
| 2633 | default: llvm_unreachable("Unknown spelling list index" ); |
| 2634 | case 0: return Keyword_constinit; |
| 2635 | case 1: return GNU_require_constant_initialization; |
| 2636 | case 2: return CXX11_clang_require_constant_initialization; |
| 2637 | } |
| 2638 | } |
| 2639 | |
| 2640 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2641 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
| 2642 | } |
| 2643 | |
| 2644 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 2645 | D->addAttr(::new (S.Context) ConstInitAttr(S.Context, Attr)); |
| 2646 | return AttributeApplied; |
| 2647 | } |
| 2648 | |
| 2649 | static const ParsedAttrInfoConstInit Instance; |
| 2650 | }; |
| 2651 | const ParsedAttrInfoConstInit ParsedAttrInfoConstInit::Instance; |
| 2652 | static constexpr ParsedAttrInfo::Spelling ConstructorSpellings[] = { |
| 2653 | {AttributeCommonInfo::AS_GNU, "constructor" }, |
| 2654 | {AttributeCommonInfo::AS_CXX11, "gnu::constructor" }, |
| 2655 | {AttributeCommonInfo::AS_C2x, "gnu::constructor" }, |
| 2656 | }; |
| 2657 | struct ParsedAttrInfoConstructor final : public ParsedAttrInfo { |
| 2658 | ParsedAttrInfoConstructor() { |
| 2659 | AttrKind = ParsedAttr::AT_Constructor; |
| 2660 | NumArgs = 0; |
| 2661 | OptArgs = 1; |
| 2662 | HasCustomParsing = 0; |
| 2663 | IsTargetSpecific = 0; |
| 2664 | IsType = 0; |
| 2665 | IsStmt = 0; |
| 2666 | IsKnownToGCC = 1; |
| 2667 | IsSupportedByPragmaAttribute = 1; |
| 2668 | Spellings = ConstructorSpellings; |
| 2669 | } |
| 2670 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2671 | if (!isa<FunctionDecl>(D)) { |
| 2672 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2673 | << Attr << "functions" ; |
| 2674 | return false; |
| 2675 | } |
| 2676 | return true; |
| 2677 | } |
| 2678 | |
| 2679 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2680 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 2681 | } |
| 2682 | |
| 2683 | static const ParsedAttrInfoConstructor Instance; |
| 2684 | }; |
| 2685 | const ParsedAttrInfoConstructor ParsedAttrInfoConstructor::Instance; |
| 2686 | static constexpr ParsedAttrInfo::Spelling ConsumableSpellings[] = { |
| 2687 | {AttributeCommonInfo::AS_GNU, "consumable" }, |
| 2688 | {AttributeCommonInfo::AS_CXX11, "clang::consumable" }, |
| 2689 | }; |
| 2690 | struct ParsedAttrInfoConsumable final : public ParsedAttrInfo { |
| 2691 | ParsedAttrInfoConsumable() { |
| 2692 | AttrKind = ParsedAttr::AT_Consumable; |
| 2693 | NumArgs = 1; |
| 2694 | OptArgs = 0; |
| 2695 | HasCustomParsing = 0; |
| 2696 | IsTargetSpecific = 0; |
| 2697 | IsType = 0; |
| 2698 | IsStmt = 0; |
| 2699 | IsKnownToGCC = 0; |
| 2700 | IsSupportedByPragmaAttribute = 1; |
| 2701 | Spellings = ConsumableSpellings; |
| 2702 | } |
| 2703 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2704 | if (!isa<CXXRecordDecl>(D)) { |
| 2705 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2706 | << Attr << "classes" ; |
| 2707 | return false; |
| 2708 | } |
| 2709 | return true; |
| 2710 | } |
| 2711 | |
| 2712 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2713 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 2714 | } |
| 2715 | |
| 2716 | static const ParsedAttrInfoConsumable Instance; |
| 2717 | }; |
| 2718 | const ParsedAttrInfoConsumable ParsedAttrInfoConsumable::Instance; |
| 2719 | static constexpr ParsedAttrInfo::Spelling ConsumableAutoCastSpellings[] = { |
| 2720 | {AttributeCommonInfo::AS_GNU, "consumable_auto_cast_state" }, |
| 2721 | {AttributeCommonInfo::AS_CXX11, "clang::consumable_auto_cast_state" }, |
| 2722 | }; |
| 2723 | struct ParsedAttrInfoConsumableAutoCast final : public ParsedAttrInfo { |
| 2724 | ParsedAttrInfoConsumableAutoCast() { |
| 2725 | AttrKind = ParsedAttr::AT_ConsumableAutoCast; |
| 2726 | NumArgs = 0; |
| 2727 | OptArgs = 0; |
| 2728 | HasCustomParsing = 0; |
| 2729 | IsTargetSpecific = 0; |
| 2730 | IsType = 0; |
| 2731 | IsStmt = 0; |
| 2732 | IsKnownToGCC = 0; |
| 2733 | IsSupportedByPragmaAttribute = 1; |
| 2734 | Spellings = ConsumableAutoCastSpellings; |
| 2735 | } |
| 2736 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2737 | if (!isa<CXXRecordDecl>(D)) { |
| 2738 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2739 | << Attr << "classes" ; |
| 2740 | return false; |
| 2741 | } |
| 2742 | return true; |
| 2743 | } |
| 2744 | |
| 2745 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2746 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 2747 | } |
| 2748 | |
| 2749 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 2750 | D->addAttr(::new (S.Context) ConsumableAutoCastAttr(S.Context, Attr)); |
| 2751 | return AttributeApplied; |
| 2752 | } |
| 2753 | |
| 2754 | static const ParsedAttrInfoConsumableAutoCast Instance; |
| 2755 | }; |
| 2756 | const ParsedAttrInfoConsumableAutoCast ParsedAttrInfoConsumableAutoCast::Instance; |
| 2757 | static constexpr ParsedAttrInfo::Spelling ConsumableSetOnReadSpellings[] = { |
| 2758 | {AttributeCommonInfo::AS_GNU, "consumable_set_state_on_read" }, |
| 2759 | {AttributeCommonInfo::AS_CXX11, "clang::consumable_set_state_on_read" }, |
| 2760 | }; |
| 2761 | struct ParsedAttrInfoConsumableSetOnRead final : public ParsedAttrInfo { |
| 2762 | ParsedAttrInfoConsumableSetOnRead() { |
| 2763 | AttrKind = ParsedAttr::AT_ConsumableSetOnRead; |
| 2764 | NumArgs = 0; |
| 2765 | OptArgs = 0; |
| 2766 | HasCustomParsing = 0; |
| 2767 | IsTargetSpecific = 0; |
| 2768 | IsType = 0; |
| 2769 | IsStmt = 0; |
| 2770 | IsKnownToGCC = 0; |
| 2771 | IsSupportedByPragmaAttribute = 1; |
| 2772 | Spellings = ConsumableSetOnReadSpellings; |
| 2773 | } |
| 2774 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2775 | if (!isa<CXXRecordDecl>(D)) { |
| 2776 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2777 | << Attr << "classes" ; |
| 2778 | return false; |
| 2779 | } |
| 2780 | return true; |
| 2781 | } |
| 2782 | |
| 2783 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2784 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 2785 | } |
| 2786 | |
| 2787 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 2788 | D->addAttr(::new (S.Context) ConsumableSetOnReadAttr(S.Context, Attr)); |
| 2789 | return AttributeApplied; |
| 2790 | } |
| 2791 | |
| 2792 | static const ParsedAttrInfoConsumableSetOnRead Instance; |
| 2793 | }; |
| 2794 | const ParsedAttrInfoConsumableSetOnRead ParsedAttrInfoConsumableSetOnRead::Instance; |
| 2795 | static constexpr ParsedAttrInfo::Spelling ConvergentSpellings[] = { |
| 2796 | {AttributeCommonInfo::AS_GNU, "convergent" }, |
| 2797 | {AttributeCommonInfo::AS_CXX11, "clang::convergent" }, |
| 2798 | {AttributeCommonInfo::AS_C2x, "clang::convergent" }, |
| 2799 | }; |
| 2800 | struct ParsedAttrInfoConvergent final : public ParsedAttrInfo { |
| 2801 | ParsedAttrInfoConvergent() { |
| 2802 | AttrKind = ParsedAttr::AT_Convergent; |
| 2803 | NumArgs = 0; |
| 2804 | OptArgs = 0; |
| 2805 | HasCustomParsing = 0; |
| 2806 | IsTargetSpecific = 0; |
| 2807 | IsType = 0; |
| 2808 | IsStmt = 0; |
| 2809 | IsKnownToGCC = 0; |
| 2810 | IsSupportedByPragmaAttribute = 1; |
| 2811 | Spellings = ConvergentSpellings; |
| 2812 | } |
| 2813 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2814 | if (!isa<FunctionDecl>(D)) { |
| 2815 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2816 | << Attr << "functions" ; |
| 2817 | return false; |
| 2818 | } |
| 2819 | return true; |
| 2820 | } |
| 2821 | |
| 2822 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2823 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 2824 | } |
| 2825 | |
| 2826 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 2827 | D->addAttr(::new (S.Context) ConvergentAttr(S.Context, Attr)); |
| 2828 | return AttributeApplied; |
| 2829 | } |
| 2830 | |
| 2831 | static const ParsedAttrInfoConvergent Instance; |
| 2832 | }; |
| 2833 | const ParsedAttrInfoConvergent ParsedAttrInfoConvergent::Instance; |
| 2834 | static constexpr ParsedAttrInfo::Spelling DLLExportSpellings[] = { |
| 2835 | {AttributeCommonInfo::AS_Declspec, "dllexport" }, |
| 2836 | {AttributeCommonInfo::AS_GNU, "dllexport" }, |
| 2837 | {AttributeCommonInfo::AS_CXX11, "gnu::dllexport" }, |
| 2838 | {AttributeCommonInfo::AS_C2x, "gnu::dllexport" }, |
| 2839 | }; |
| 2840 | struct ParsedAttrInfoDLLExport final : public ParsedAttrInfo { |
| 2841 | ParsedAttrInfoDLLExport() { |
| 2842 | AttrKind = ParsedAttr::AT_DLLExport; |
| 2843 | NumArgs = 0; |
| 2844 | OptArgs = 0; |
| 2845 | HasCustomParsing = 0; |
| 2846 | IsTargetSpecific = 1; |
| 2847 | IsType = 0; |
| 2848 | IsStmt = 0; |
| 2849 | IsKnownToGCC = 1; |
| 2850 | IsSupportedByPragmaAttribute = 1; |
| 2851 | Spellings = DLLExportSpellings; |
| 2852 | } |
| 2853 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2854 | if (!isa<FunctionDecl>(D) && !isa<VarDecl>(D) && !isa<CXXRecordDecl>(D) && !isa<ObjCInterfaceDecl>(D)) { |
| 2855 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2856 | << Attr << "functions, variables, classes, and Objective-C interfaces" ; |
| 2857 | return false; |
| 2858 | } |
| 2859 | return true; |
| 2860 | } |
| 2861 | |
| 2862 | bool existsInTarget(const TargetInfo &Target) const override { |
| 2863 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 2864 | return true && ( Target.getTriple().hasDLLImportExport() ); |
| 2865 | } |
| 2866 | |
| 2867 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2868 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 2869 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 2870 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 2871 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 2872 | } |
| 2873 | |
| 2874 | static const ParsedAttrInfoDLLExport Instance; |
| 2875 | }; |
| 2876 | const ParsedAttrInfoDLLExport ParsedAttrInfoDLLExport::Instance; |
| 2877 | struct ParsedAttrInfoDLLExportStaticLocal final : public ParsedAttrInfo { |
| 2878 | ParsedAttrInfoDLLExportStaticLocal() { |
| 2879 | AttrKind = ParsedAttr::AT_DLLExportStaticLocal; |
| 2880 | NumArgs = 0; |
| 2881 | OptArgs = 0; |
| 2882 | HasCustomParsing = 0; |
| 2883 | IsTargetSpecific = 1; |
| 2884 | IsType = 0; |
| 2885 | IsStmt = 0; |
| 2886 | IsKnownToGCC = 0; |
| 2887 | IsSupportedByPragmaAttribute = 0; |
| 2888 | } |
| 2889 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2890 | if (!isa<FunctionDecl>(D)) { |
| 2891 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2892 | << Attr << "functions" ; |
| 2893 | return false; |
| 2894 | } |
| 2895 | return true; |
| 2896 | } |
| 2897 | |
| 2898 | bool existsInTarget(const TargetInfo &Target) const override { |
| 2899 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 2900 | return true && ( Target.getTriple().hasDLLImportExport() ); |
| 2901 | } |
| 2902 | |
| 2903 | static const ParsedAttrInfoDLLExportStaticLocal Instance; |
| 2904 | }; |
| 2905 | const ParsedAttrInfoDLLExportStaticLocal ParsedAttrInfoDLLExportStaticLocal::Instance; |
| 2906 | static constexpr ParsedAttrInfo::Spelling DLLImportSpellings[] = { |
| 2907 | {AttributeCommonInfo::AS_Declspec, "dllimport" }, |
| 2908 | {AttributeCommonInfo::AS_GNU, "dllimport" }, |
| 2909 | {AttributeCommonInfo::AS_CXX11, "gnu::dllimport" }, |
| 2910 | {AttributeCommonInfo::AS_C2x, "gnu::dllimport" }, |
| 2911 | }; |
| 2912 | struct ParsedAttrInfoDLLImport final : public ParsedAttrInfo { |
| 2913 | ParsedAttrInfoDLLImport() { |
| 2914 | AttrKind = ParsedAttr::AT_DLLImport; |
| 2915 | NumArgs = 0; |
| 2916 | OptArgs = 0; |
| 2917 | HasCustomParsing = 0; |
| 2918 | IsTargetSpecific = 1; |
| 2919 | IsType = 0; |
| 2920 | IsStmt = 0; |
| 2921 | IsKnownToGCC = 1; |
| 2922 | IsSupportedByPragmaAttribute = 1; |
| 2923 | Spellings = DLLImportSpellings; |
| 2924 | } |
| 2925 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2926 | if (!isa<FunctionDecl>(D) && !isa<VarDecl>(D) && !isa<CXXRecordDecl>(D) && !isa<ObjCInterfaceDecl>(D)) { |
| 2927 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2928 | << Attr << "functions, variables, classes, and Objective-C interfaces" ; |
| 2929 | return false; |
| 2930 | } |
| 2931 | return true; |
| 2932 | } |
| 2933 | |
| 2934 | bool existsInTarget(const TargetInfo &Target) const override { |
| 2935 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 2936 | return true && ( Target.getTriple().hasDLLImportExport() ); |
| 2937 | } |
| 2938 | |
| 2939 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 2940 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 2941 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 2942 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 2943 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 2944 | } |
| 2945 | |
| 2946 | static const ParsedAttrInfoDLLImport Instance; |
| 2947 | }; |
| 2948 | const ParsedAttrInfoDLLImport ParsedAttrInfoDLLImport::Instance; |
| 2949 | struct ParsedAttrInfoDLLImportStaticLocal final : public ParsedAttrInfo { |
| 2950 | ParsedAttrInfoDLLImportStaticLocal() { |
| 2951 | AttrKind = ParsedAttr::AT_DLLImportStaticLocal; |
| 2952 | NumArgs = 0; |
| 2953 | OptArgs = 0; |
| 2954 | HasCustomParsing = 0; |
| 2955 | IsTargetSpecific = 1; |
| 2956 | IsType = 0; |
| 2957 | IsStmt = 0; |
| 2958 | IsKnownToGCC = 0; |
| 2959 | IsSupportedByPragmaAttribute = 0; |
| 2960 | } |
| 2961 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 2962 | if (!isa<FunctionDecl>(D)) { |
| 2963 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 2964 | << Attr << "functions" ; |
| 2965 | return false; |
| 2966 | } |
| 2967 | return true; |
| 2968 | } |
| 2969 | |
| 2970 | bool existsInTarget(const TargetInfo &Target) const override { |
| 2971 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 2972 | return true && ( Target.getTriple().hasDLLImportExport() ); |
| 2973 | } |
| 2974 | |
| 2975 | static const ParsedAttrInfoDLLImportStaticLocal Instance; |
| 2976 | }; |
| 2977 | const ParsedAttrInfoDLLImportStaticLocal ParsedAttrInfoDLLImportStaticLocal::Instance; |
| 2978 | static constexpr ParsedAttrInfo::Spelling DeprecatedSpellings[] = { |
| 2979 | {AttributeCommonInfo::AS_GNU, "deprecated" }, |
| 2980 | {AttributeCommonInfo::AS_CXX11, "gnu::deprecated" }, |
| 2981 | {AttributeCommonInfo::AS_C2x, "gnu::deprecated" }, |
| 2982 | {AttributeCommonInfo::AS_Declspec, "deprecated" }, |
| 2983 | {AttributeCommonInfo::AS_CXX11, "deprecated" }, |
| 2984 | {AttributeCommonInfo::AS_C2x, "deprecated" }, |
| 2985 | }; |
| 2986 | struct ParsedAttrInfoDeprecated final : public ParsedAttrInfo { |
| 2987 | ParsedAttrInfoDeprecated() { |
| 2988 | AttrKind = ParsedAttr::AT_Deprecated; |
| 2989 | NumArgs = 0; |
| 2990 | OptArgs = 2; |
| 2991 | HasCustomParsing = 0; |
| 2992 | IsTargetSpecific = 0; |
| 2993 | IsType = 0; |
| 2994 | IsStmt = 0; |
| 2995 | IsKnownToGCC = 1; |
| 2996 | IsSupportedByPragmaAttribute = 0; |
| 2997 | Spellings = DeprecatedSpellings; |
| 2998 | } |
| 2999 | static const ParsedAttrInfoDeprecated Instance; |
| 3000 | }; |
| 3001 | const ParsedAttrInfoDeprecated ParsedAttrInfoDeprecated::Instance; |
| 3002 | static constexpr ParsedAttrInfo::Spelling DestructorSpellings[] = { |
| 3003 | {AttributeCommonInfo::AS_GNU, "destructor" }, |
| 3004 | {AttributeCommonInfo::AS_CXX11, "gnu::destructor" }, |
| 3005 | {AttributeCommonInfo::AS_C2x, "gnu::destructor" }, |
| 3006 | }; |
| 3007 | struct ParsedAttrInfoDestructor final : public ParsedAttrInfo { |
| 3008 | ParsedAttrInfoDestructor() { |
| 3009 | AttrKind = ParsedAttr::AT_Destructor; |
| 3010 | NumArgs = 0; |
| 3011 | OptArgs = 1; |
| 3012 | HasCustomParsing = 0; |
| 3013 | IsTargetSpecific = 0; |
| 3014 | IsType = 0; |
| 3015 | IsStmt = 0; |
| 3016 | IsKnownToGCC = 1; |
| 3017 | IsSupportedByPragmaAttribute = 1; |
| 3018 | Spellings = DestructorSpellings; |
| 3019 | } |
| 3020 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3021 | if (!isa<FunctionDecl>(D)) { |
| 3022 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3023 | << Attr << "functions" ; |
| 3024 | return false; |
| 3025 | } |
| 3026 | return true; |
| 3027 | } |
| 3028 | |
| 3029 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3030 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3031 | } |
| 3032 | |
| 3033 | static const ParsedAttrInfoDestructor Instance; |
| 3034 | }; |
| 3035 | const ParsedAttrInfoDestructor ParsedAttrInfoDestructor::Instance; |
| 3036 | static constexpr ParsedAttrInfo::Spelling DiagnoseIfSpellings[] = { |
| 3037 | {AttributeCommonInfo::AS_GNU, "diagnose_if" }, |
| 3038 | }; |
| 3039 | struct ParsedAttrInfoDiagnoseIf final : public ParsedAttrInfo { |
| 3040 | ParsedAttrInfoDiagnoseIf() { |
| 3041 | AttrKind = ParsedAttr::AT_DiagnoseIf; |
| 3042 | NumArgs = 3; |
| 3043 | OptArgs = 0; |
| 3044 | HasCustomParsing = 0; |
| 3045 | IsTargetSpecific = 0; |
| 3046 | IsType = 0; |
| 3047 | IsStmt = 0; |
| 3048 | IsKnownToGCC = 0; |
| 3049 | IsSupportedByPragmaAttribute = 0; |
| 3050 | Spellings = DiagnoseIfSpellings; |
| 3051 | } |
| 3052 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3053 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D)) { |
| 3054 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3055 | << Attr << "functions, Objective-C methods, and Objective-C properties" ; |
| 3056 | return false; |
| 3057 | } |
| 3058 | return true; |
| 3059 | } |
| 3060 | |
| 3061 | static const ParsedAttrInfoDiagnoseIf Instance; |
| 3062 | }; |
| 3063 | const ParsedAttrInfoDiagnoseIf ParsedAttrInfoDiagnoseIf::Instance; |
| 3064 | static constexpr ParsedAttrInfo::Spelling DisableTailCallsSpellings[] = { |
| 3065 | {AttributeCommonInfo::AS_GNU, "disable_tail_calls" }, |
| 3066 | {AttributeCommonInfo::AS_CXX11, "clang::disable_tail_calls" }, |
| 3067 | {AttributeCommonInfo::AS_C2x, "clang::disable_tail_calls" }, |
| 3068 | }; |
| 3069 | struct ParsedAttrInfoDisableTailCalls final : public ParsedAttrInfo { |
| 3070 | ParsedAttrInfoDisableTailCalls() { |
| 3071 | AttrKind = ParsedAttr::AT_DisableTailCalls; |
| 3072 | NumArgs = 0; |
| 3073 | OptArgs = 0; |
| 3074 | HasCustomParsing = 0; |
| 3075 | IsTargetSpecific = 0; |
| 3076 | IsType = 0; |
| 3077 | IsStmt = 0; |
| 3078 | IsKnownToGCC = 0; |
| 3079 | IsSupportedByPragmaAttribute = 1; |
| 3080 | Spellings = DisableTailCallsSpellings; |
| 3081 | } |
| 3082 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3083 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 3084 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3085 | << Attr << "functions and Objective-C methods" ; |
| 3086 | return false; |
| 3087 | } |
| 3088 | return true; |
| 3089 | } |
| 3090 | |
| 3091 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3092 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3093 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 3094 | } |
| 3095 | |
| 3096 | static const ParsedAttrInfoDisableTailCalls Instance; |
| 3097 | }; |
| 3098 | const ParsedAttrInfoDisableTailCalls ParsedAttrInfoDisableTailCalls::Instance; |
| 3099 | static constexpr ParsedAttrInfo::Spelling EmptyBasesSpellings[] = { |
| 3100 | {AttributeCommonInfo::AS_Declspec, "empty_bases" }, |
| 3101 | }; |
| 3102 | struct ParsedAttrInfoEmptyBases final : public ParsedAttrInfo { |
| 3103 | ParsedAttrInfoEmptyBases() { |
| 3104 | AttrKind = ParsedAttr::AT_EmptyBases; |
| 3105 | NumArgs = 0; |
| 3106 | OptArgs = 0; |
| 3107 | HasCustomParsing = 0; |
| 3108 | IsTargetSpecific = 1; |
| 3109 | IsType = 0; |
| 3110 | IsStmt = 0; |
| 3111 | IsKnownToGCC = 0; |
| 3112 | IsSupportedByPragmaAttribute = 0; |
| 3113 | Spellings = EmptyBasesSpellings; |
| 3114 | } |
| 3115 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3116 | if (!isa<CXXRecordDecl>(D)) { |
| 3117 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3118 | << Attr << "classes" ; |
| 3119 | return false; |
| 3120 | } |
| 3121 | return true; |
| 3122 | } |
| 3123 | |
| 3124 | bool existsInTarget(const TargetInfo &Target) const override { |
| 3125 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 3126 | return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64 || T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::aarch64) && ( Target.getCXXABI().isMicrosoft() ); |
| 3127 | } |
| 3128 | |
| 3129 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 3130 | D->addAttr(::new (S.Context) EmptyBasesAttr(S.Context, Attr)); |
| 3131 | return AttributeApplied; |
| 3132 | } |
| 3133 | |
| 3134 | static const ParsedAttrInfoEmptyBases Instance; |
| 3135 | }; |
| 3136 | const ParsedAttrInfoEmptyBases ParsedAttrInfoEmptyBases::Instance; |
| 3137 | static constexpr ParsedAttrInfo::Spelling EnableIfSpellings[] = { |
| 3138 | {AttributeCommonInfo::AS_GNU, "enable_if" }, |
| 3139 | }; |
| 3140 | struct ParsedAttrInfoEnableIf final : public ParsedAttrInfo { |
| 3141 | ParsedAttrInfoEnableIf() { |
| 3142 | AttrKind = ParsedAttr::AT_EnableIf; |
| 3143 | NumArgs = 2; |
| 3144 | OptArgs = 0; |
| 3145 | HasCustomParsing = 0; |
| 3146 | IsTargetSpecific = 0; |
| 3147 | IsType = 0; |
| 3148 | IsStmt = 0; |
| 3149 | IsKnownToGCC = 0; |
| 3150 | IsSupportedByPragmaAttribute = 1; |
| 3151 | Spellings = EnableIfSpellings; |
| 3152 | } |
| 3153 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3154 | if (!isa<FunctionDecl>(D)) { |
| 3155 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3156 | << Attr << "functions" ; |
| 3157 | return false; |
| 3158 | } |
| 3159 | return true; |
| 3160 | } |
| 3161 | |
| 3162 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3163 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3164 | } |
| 3165 | |
| 3166 | static const ParsedAttrInfoEnableIf Instance; |
| 3167 | }; |
| 3168 | const ParsedAttrInfoEnableIf ParsedAttrInfoEnableIf::Instance; |
| 3169 | static constexpr ParsedAttrInfo::Spelling EnforceTCBSpellings[] = { |
| 3170 | {AttributeCommonInfo::AS_GNU, "enforce_tcb" }, |
| 3171 | {AttributeCommonInfo::AS_CXX11, "clang::enforce_tcb" }, |
| 3172 | {AttributeCommonInfo::AS_C2x, "clang::enforce_tcb" }, |
| 3173 | }; |
| 3174 | struct ParsedAttrInfoEnforceTCB final : public ParsedAttrInfo { |
| 3175 | ParsedAttrInfoEnforceTCB() { |
| 3176 | AttrKind = ParsedAttr::AT_EnforceTCB; |
| 3177 | NumArgs = 1; |
| 3178 | OptArgs = 0; |
| 3179 | HasCustomParsing = 0; |
| 3180 | IsTargetSpecific = 0; |
| 3181 | IsType = 0; |
| 3182 | IsStmt = 0; |
| 3183 | IsKnownToGCC = 0; |
| 3184 | IsSupportedByPragmaAttribute = 1; |
| 3185 | Spellings = EnforceTCBSpellings; |
| 3186 | } |
| 3187 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3188 | if (!isa<FunctionDecl>(D)) { |
| 3189 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3190 | << Attr << "functions" ; |
| 3191 | return false; |
| 3192 | } |
| 3193 | return true; |
| 3194 | } |
| 3195 | |
| 3196 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3197 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3198 | } |
| 3199 | |
| 3200 | static const ParsedAttrInfoEnforceTCB Instance; |
| 3201 | }; |
| 3202 | const ParsedAttrInfoEnforceTCB ParsedAttrInfoEnforceTCB::Instance; |
| 3203 | static constexpr ParsedAttrInfo::Spelling EnforceTCBLeafSpellings[] = { |
| 3204 | {AttributeCommonInfo::AS_GNU, "enforce_tcb_leaf" }, |
| 3205 | {AttributeCommonInfo::AS_CXX11, "clang::enforce_tcb_leaf" }, |
| 3206 | {AttributeCommonInfo::AS_C2x, "clang::enforce_tcb_leaf" }, |
| 3207 | }; |
| 3208 | struct ParsedAttrInfoEnforceTCBLeaf final : public ParsedAttrInfo { |
| 3209 | ParsedAttrInfoEnforceTCBLeaf() { |
| 3210 | AttrKind = ParsedAttr::AT_EnforceTCBLeaf; |
| 3211 | NumArgs = 1; |
| 3212 | OptArgs = 0; |
| 3213 | HasCustomParsing = 0; |
| 3214 | IsTargetSpecific = 0; |
| 3215 | IsType = 0; |
| 3216 | IsStmt = 0; |
| 3217 | IsKnownToGCC = 0; |
| 3218 | IsSupportedByPragmaAttribute = 1; |
| 3219 | Spellings = EnforceTCBLeafSpellings; |
| 3220 | } |
| 3221 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3222 | if (!isa<FunctionDecl>(D)) { |
| 3223 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3224 | << Attr << "functions" ; |
| 3225 | return false; |
| 3226 | } |
| 3227 | return true; |
| 3228 | } |
| 3229 | |
| 3230 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3231 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3232 | } |
| 3233 | |
| 3234 | static const ParsedAttrInfoEnforceTCBLeaf Instance; |
| 3235 | }; |
| 3236 | const ParsedAttrInfoEnforceTCBLeaf ParsedAttrInfoEnforceTCBLeaf::Instance; |
| 3237 | static constexpr ParsedAttrInfo::Spelling EnumExtensibilitySpellings[] = { |
| 3238 | {AttributeCommonInfo::AS_GNU, "enum_extensibility" }, |
| 3239 | {AttributeCommonInfo::AS_CXX11, "clang::enum_extensibility" }, |
| 3240 | {AttributeCommonInfo::AS_C2x, "clang::enum_extensibility" }, |
| 3241 | }; |
| 3242 | struct ParsedAttrInfoEnumExtensibility final : public ParsedAttrInfo { |
| 3243 | ParsedAttrInfoEnumExtensibility() { |
| 3244 | AttrKind = ParsedAttr::AT_EnumExtensibility; |
| 3245 | NumArgs = 1; |
| 3246 | OptArgs = 0; |
| 3247 | HasCustomParsing = 0; |
| 3248 | IsTargetSpecific = 0; |
| 3249 | IsType = 0; |
| 3250 | IsStmt = 0; |
| 3251 | IsKnownToGCC = 0; |
| 3252 | IsSupportedByPragmaAttribute = 1; |
| 3253 | Spellings = EnumExtensibilitySpellings; |
| 3254 | } |
| 3255 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3256 | if (!isa<EnumDecl>(D)) { |
| 3257 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3258 | << Attr << "enums" ; |
| 3259 | return false; |
| 3260 | } |
| 3261 | return true; |
| 3262 | } |
| 3263 | |
| 3264 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3265 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
| 3266 | } |
| 3267 | |
| 3268 | static const ParsedAttrInfoEnumExtensibility Instance; |
| 3269 | }; |
| 3270 | const ParsedAttrInfoEnumExtensibility ParsedAttrInfoEnumExtensibility::Instance; |
| 3271 | static constexpr ParsedAttrInfo::Spelling ExcludeFromExplicitInstantiationSpellings[] = { |
| 3272 | {AttributeCommonInfo::AS_GNU, "exclude_from_explicit_instantiation" }, |
| 3273 | {AttributeCommonInfo::AS_CXX11, "clang::exclude_from_explicit_instantiation" }, |
| 3274 | {AttributeCommonInfo::AS_C2x, "clang::exclude_from_explicit_instantiation" }, |
| 3275 | }; |
| 3276 | struct ParsedAttrInfoExcludeFromExplicitInstantiation final : public ParsedAttrInfo { |
| 3277 | ParsedAttrInfoExcludeFromExplicitInstantiation() { |
| 3278 | AttrKind = ParsedAttr::AT_ExcludeFromExplicitInstantiation; |
| 3279 | NumArgs = 0; |
| 3280 | OptArgs = 0; |
| 3281 | HasCustomParsing = 0; |
| 3282 | IsTargetSpecific = 0; |
| 3283 | IsType = 0; |
| 3284 | IsStmt = 0; |
| 3285 | IsKnownToGCC = 0; |
| 3286 | IsSupportedByPragmaAttribute = 1; |
| 3287 | Spellings = ExcludeFromExplicitInstantiationSpellings; |
| 3288 | } |
| 3289 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3290 | if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D)) { |
| 3291 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3292 | << Attr << "variables, functions, and classes" ; |
| 3293 | return false; |
| 3294 | } |
| 3295 | return true; |
| 3296 | } |
| 3297 | |
| 3298 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3299 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 3300 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3301 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 3302 | } |
| 3303 | |
| 3304 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 3305 | D->addAttr(::new (S.Context) ExcludeFromExplicitInstantiationAttr(S.Context, Attr)); |
| 3306 | return AttributeApplied; |
| 3307 | } |
| 3308 | |
| 3309 | static const ParsedAttrInfoExcludeFromExplicitInstantiation Instance; |
| 3310 | }; |
| 3311 | const ParsedAttrInfoExcludeFromExplicitInstantiation ParsedAttrInfoExcludeFromExplicitInstantiation::Instance; |
| 3312 | static constexpr ParsedAttrInfo::Spelling ExclusiveTrylockFunctionSpellings[] = { |
| 3313 | {AttributeCommonInfo::AS_GNU, "exclusive_trylock_function" }, |
| 3314 | }; |
| 3315 | struct ParsedAttrInfoExclusiveTrylockFunction final : public ParsedAttrInfo { |
| 3316 | ParsedAttrInfoExclusiveTrylockFunction() { |
| 3317 | AttrKind = ParsedAttr::AT_ExclusiveTrylockFunction; |
| 3318 | NumArgs = 1; |
| 3319 | OptArgs = 15; |
| 3320 | HasCustomParsing = 0; |
| 3321 | IsTargetSpecific = 0; |
| 3322 | IsType = 0; |
| 3323 | IsStmt = 0; |
| 3324 | IsKnownToGCC = 0; |
| 3325 | IsSupportedByPragmaAttribute = 0; |
| 3326 | Spellings = ExclusiveTrylockFunctionSpellings; |
| 3327 | } |
| 3328 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3329 | if (!isa<FunctionDecl>(D)) { |
| 3330 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3331 | << Attr << "functions" ; |
| 3332 | return false; |
| 3333 | } |
| 3334 | return true; |
| 3335 | } |
| 3336 | |
| 3337 | static const ParsedAttrInfoExclusiveTrylockFunction Instance; |
| 3338 | }; |
| 3339 | const ParsedAttrInfoExclusiveTrylockFunction ParsedAttrInfoExclusiveTrylockFunction::Instance; |
| 3340 | static constexpr ParsedAttrInfo::Spelling ExtVectorTypeSpellings[] = { |
| 3341 | {AttributeCommonInfo::AS_GNU, "ext_vector_type" }, |
| 3342 | }; |
| 3343 | struct ParsedAttrInfoExtVectorType final : public ParsedAttrInfo { |
| 3344 | ParsedAttrInfoExtVectorType() { |
| 3345 | AttrKind = ParsedAttr::AT_ExtVectorType; |
| 3346 | NumArgs = 1; |
| 3347 | OptArgs = 0; |
| 3348 | HasCustomParsing = 0; |
| 3349 | IsTargetSpecific = 0; |
| 3350 | IsType = 0; |
| 3351 | IsStmt = 0; |
| 3352 | IsKnownToGCC = 0; |
| 3353 | IsSupportedByPragmaAttribute = 0; |
| 3354 | Spellings = ExtVectorTypeSpellings; |
| 3355 | } |
| 3356 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3357 | if (!isa<TypedefNameDecl>(D)) { |
| 3358 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 3359 | << Attr << "typedefs" ; |
| 3360 | return false; |
| 3361 | } |
| 3362 | return true; |
| 3363 | } |
| 3364 | |
| 3365 | static const ParsedAttrInfoExtVectorType Instance; |
| 3366 | }; |
| 3367 | const ParsedAttrInfoExtVectorType ParsedAttrInfoExtVectorType::Instance; |
| 3368 | static constexpr ParsedAttrInfo::Spelling ExternalSourceSymbolSpellings[] = { |
| 3369 | {AttributeCommonInfo::AS_GNU, "external_source_symbol" }, |
| 3370 | {AttributeCommonInfo::AS_CXX11, "clang::external_source_symbol" }, |
| 3371 | {AttributeCommonInfo::AS_C2x, "clang::external_source_symbol" }, |
| 3372 | }; |
| 3373 | struct ParsedAttrInfoExternalSourceSymbol final : public ParsedAttrInfo { |
| 3374 | ParsedAttrInfoExternalSourceSymbol() { |
| 3375 | AttrKind = ParsedAttr::AT_ExternalSourceSymbol; |
| 3376 | NumArgs = 0; |
| 3377 | OptArgs = 3; |
| 3378 | HasCustomParsing = 1; |
| 3379 | IsTargetSpecific = 0; |
| 3380 | IsType = 0; |
| 3381 | IsStmt = 0; |
| 3382 | IsKnownToGCC = 0; |
| 3383 | IsSupportedByPragmaAttribute = 1; |
| 3384 | Spellings = ExternalSourceSymbolSpellings; |
| 3385 | } |
| 3386 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3387 | if (!isa<NamedDecl>(D)) { |
| 3388 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3389 | << Attr << "named declarations" ; |
| 3390 | return false; |
| 3391 | } |
| 3392 | return true; |
| 3393 | } |
| 3394 | |
| 3395 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3396 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 3397 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
| 3398 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum_constant, /*IsSupported=*/true)); |
| 3399 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_field, /*IsSupported=*/true)); |
| 3400 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3401 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_namespace, /*IsSupported=*/LangOpts.CPlusPlus)); |
| 3402 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_category, /*IsSupported=*/LangOpts.ObjC)); |
| 3403 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_implementation, /*IsSupported=*/LangOpts.ObjC)); |
| 3404 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 3405 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 3406 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
| 3407 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC)); |
| 3408 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 3409 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
| 3410 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 3411 | } |
| 3412 | |
| 3413 | static const ParsedAttrInfoExternalSourceSymbol Instance; |
| 3414 | }; |
| 3415 | const ParsedAttrInfoExternalSourceSymbol ParsedAttrInfoExternalSourceSymbol::Instance; |
| 3416 | static constexpr ParsedAttrInfo::Spelling FallThroughSpellings[] = { |
| 3417 | {AttributeCommonInfo::AS_CXX11, "fallthrough" }, |
| 3418 | {AttributeCommonInfo::AS_C2x, "fallthrough" }, |
| 3419 | {AttributeCommonInfo::AS_CXX11, "clang::fallthrough" }, |
| 3420 | {AttributeCommonInfo::AS_GNU, "fallthrough" }, |
| 3421 | {AttributeCommonInfo::AS_CXX11, "gnu::fallthrough" }, |
| 3422 | {AttributeCommonInfo::AS_C2x, "gnu::fallthrough" }, |
| 3423 | }; |
| 3424 | struct ParsedAttrInfoFallThrough final : public ParsedAttrInfo { |
| 3425 | ParsedAttrInfoFallThrough() { |
| 3426 | AttrKind = ParsedAttr::AT_FallThrough; |
| 3427 | NumArgs = 0; |
| 3428 | OptArgs = 0; |
| 3429 | HasCustomParsing = 0; |
| 3430 | IsTargetSpecific = 0; |
| 3431 | IsType = 0; |
| 3432 | IsStmt = 1; |
| 3433 | IsKnownToGCC = 1; |
| 3434 | IsSupportedByPragmaAttribute = 0; |
| 3435 | Spellings = FallThroughSpellings; |
| 3436 | } |
| 3437 | static const ParsedAttrInfoFallThrough Instance; |
| 3438 | }; |
| 3439 | const ParsedAttrInfoFallThrough ParsedAttrInfoFallThrough::Instance; |
| 3440 | static constexpr ParsedAttrInfo::Spelling FastCallSpellings[] = { |
| 3441 | {AttributeCommonInfo::AS_GNU, "fastcall" }, |
| 3442 | {AttributeCommonInfo::AS_CXX11, "gnu::fastcall" }, |
| 3443 | {AttributeCommonInfo::AS_C2x, "gnu::fastcall" }, |
| 3444 | {AttributeCommonInfo::AS_Keyword, "__fastcall" }, |
| 3445 | {AttributeCommonInfo::AS_Keyword, "_fastcall" }, |
| 3446 | }; |
| 3447 | struct ParsedAttrInfoFastCall final : public ParsedAttrInfo { |
| 3448 | ParsedAttrInfoFastCall() { |
| 3449 | AttrKind = ParsedAttr::AT_FastCall; |
| 3450 | NumArgs = 0; |
| 3451 | OptArgs = 0; |
| 3452 | HasCustomParsing = 0; |
| 3453 | IsTargetSpecific = 0; |
| 3454 | IsType = 1; |
| 3455 | IsStmt = 0; |
| 3456 | IsKnownToGCC = 1; |
| 3457 | IsSupportedByPragmaAttribute = 0; |
| 3458 | Spellings = FastCallSpellings; |
| 3459 | } |
| 3460 | static const ParsedAttrInfoFastCall Instance; |
| 3461 | }; |
| 3462 | const ParsedAttrInfoFastCall ParsedAttrInfoFastCall::Instance; |
| 3463 | static constexpr ParsedAttrInfo::Spelling FlagEnumSpellings[] = { |
| 3464 | {AttributeCommonInfo::AS_GNU, "flag_enum" }, |
| 3465 | {AttributeCommonInfo::AS_CXX11, "clang::flag_enum" }, |
| 3466 | {AttributeCommonInfo::AS_C2x, "clang::flag_enum" }, |
| 3467 | }; |
| 3468 | struct ParsedAttrInfoFlagEnum final : public ParsedAttrInfo { |
| 3469 | ParsedAttrInfoFlagEnum() { |
| 3470 | AttrKind = ParsedAttr::AT_FlagEnum; |
| 3471 | NumArgs = 0; |
| 3472 | OptArgs = 0; |
| 3473 | HasCustomParsing = 0; |
| 3474 | IsTargetSpecific = 0; |
| 3475 | IsType = 0; |
| 3476 | IsStmt = 0; |
| 3477 | IsKnownToGCC = 0; |
| 3478 | IsSupportedByPragmaAttribute = 1; |
| 3479 | Spellings = FlagEnumSpellings; |
| 3480 | } |
| 3481 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3482 | if (!isa<EnumDecl>(D)) { |
| 3483 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3484 | << Attr << "enums" ; |
| 3485 | return false; |
| 3486 | } |
| 3487 | return true; |
| 3488 | } |
| 3489 | |
| 3490 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3491 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
| 3492 | } |
| 3493 | |
| 3494 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 3495 | D->addAttr(::new (S.Context) FlagEnumAttr(S.Context, Attr)); |
| 3496 | return AttributeApplied; |
| 3497 | } |
| 3498 | |
| 3499 | static const ParsedAttrInfoFlagEnum Instance; |
| 3500 | }; |
| 3501 | const ParsedAttrInfoFlagEnum ParsedAttrInfoFlagEnum::Instance; |
| 3502 | static constexpr ParsedAttrInfo::Spelling FlattenSpellings[] = { |
| 3503 | {AttributeCommonInfo::AS_GNU, "flatten" }, |
| 3504 | {AttributeCommonInfo::AS_CXX11, "gnu::flatten" }, |
| 3505 | {AttributeCommonInfo::AS_C2x, "gnu::flatten" }, |
| 3506 | }; |
| 3507 | struct ParsedAttrInfoFlatten final : public ParsedAttrInfo { |
| 3508 | ParsedAttrInfoFlatten() { |
| 3509 | AttrKind = ParsedAttr::AT_Flatten; |
| 3510 | NumArgs = 0; |
| 3511 | OptArgs = 0; |
| 3512 | HasCustomParsing = 0; |
| 3513 | IsTargetSpecific = 0; |
| 3514 | IsType = 0; |
| 3515 | IsStmt = 0; |
| 3516 | IsKnownToGCC = 1; |
| 3517 | IsSupportedByPragmaAttribute = 1; |
| 3518 | Spellings = FlattenSpellings; |
| 3519 | } |
| 3520 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3521 | if (!isa<FunctionDecl>(D)) { |
| 3522 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 3523 | << Attr << "functions" ; |
| 3524 | return false; |
| 3525 | } |
| 3526 | return true; |
| 3527 | } |
| 3528 | |
| 3529 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3530 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3531 | } |
| 3532 | |
| 3533 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 3534 | D->addAttr(::new (S.Context) FlattenAttr(S.Context, Attr)); |
| 3535 | return AttributeApplied; |
| 3536 | } |
| 3537 | |
| 3538 | static const ParsedAttrInfoFlatten Instance; |
| 3539 | }; |
| 3540 | const ParsedAttrInfoFlatten ParsedAttrInfoFlatten::Instance; |
| 3541 | static constexpr ParsedAttrInfo::Spelling FormatSpellings[] = { |
| 3542 | {AttributeCommonInfo::AS_GNU, "format" }, |
| 3543 | {AttributeCommonInfo::AS_CXX11, "gnu::format" }, |
| 3544 | {AttributeCommonInfo::AS_C2x, "gnu::format" }, |
| 3545 | }; |
| 3546 | struct ParsedAttrInfoFormat final : public ParsedAttrInfo { |
| 3547 | ParsedAttrInfoFormat() { |
| 3548 | AttrKind = ParsedAttr::AT_Format; |
| 3549 | NumArgs = 3; |
| 3550 | OptArgs = 0; |
| 3551 | HasCustomParsing = 0; |
| 3552 | IsTargetSpecific = 0; |
| 3553 | IsType = 0; |
| 3554 | IsStmt = 0; |
| 3555 | IsKnownToGCC = 1; |
| 3556 | IsSupportedByPragmaAttribute = 0; |
| 3557 | Spellings = FormatSpellings; |
| 3558 | } |
| 3559 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3560 | if (!isa<ObjCMethodDecl>(D) && !isa<BlockDecl>(D) && !isHasFunctionProto(D)) { |
| 3561 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3562 | << Attr << "Objective-C methods, blocks, and non-K&R-style functions" ; |
| 3563 | return false; |
| 3564 | } |
| 3565 | return true; |
| 3566 | } |
| 3567 | |
| 3568 | static const ParsedAttrInfoFormat Instance; |
| 3569 | }; |
| 3570 | const ParsedAttrInfoFormat ParsedAttrInfoFormat::Instance; |
| 3571 | static constexpr ParsedAttrInfo::Spelling FormatArgSpellings[] = { |
| 3572 | {AttributeCommonInfo::AS_GNU, "format_arg" }, |
| 3573 | {AttributeCommonInfo::AS_CXX11, "gnu::format_arg" }, |
| 3574 | {AttributeCommonInfo::AS_C2x, "gnu::format_arg" }, |
| 3575 | }; |
| 3576 | struct ParsedAttrInfoFormatArg final : public ParsedAttrInfo { |
| 3577 | ParsedAttrInfoFormatArg() { |
| 3578 | AttrKind = ParsedAttr::AT_FormatArg; |
| 3579 | NumArgs = 1; |
| 3580 | OptArgs = 0; |
| 3581 | HasCustomParsing = 0; |
| 3582 | IsTargetSpecific = 0; |
| 3583 | IsType = 0; |
| 3584 | IsStmt = 0; |
| 3585 | IsKnownToGCC = 1; |
| 3586 | IsSupportedByPragmaAttribute = 0; |
| 3587 | Spellings = FormatArgSpellings; |
| 3588 | } |
| 3589 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3590 | if (!isa<ObjCMethodDecl>(D) && !isHasFunctionProto(D)) { |
| 3591 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3592 | << Attr << "Objective-C methods and non-K&R-style functions" ; |
| 3593 | return false; |
| 3594 | } |
| 3595 | return true; |
| 3596 | } |
| 3597 | |
| 3598 | static const ParsedAttrInfoFormatArg Instance; |
| 3599 | }; |
| 3600 | const ParsedAttrInfoFormatArg ParsedAttrInfoFormatArg::Instance; |
| 3601 | static constexpr ParsedAttrInfo::Spelling GNUInlineSpellings[] = { |
| 3602 | {AttributeCommonInfo::AS_GNU, "gnu_inline" }, |
| 3603 | {AttributeCommonInfo::AS_CXX11, "gnu::gnu_inline" }, |
| 3604 | {AttributeCommonInfo::AS_C2x, "gnu::gnu_inline" }, |
| 3605 | }; |
| 3606 | struct ParsedAttrInfoGNUInline final : public ParsedAttrInfo { |
| 3607 | ParsedAttrInfoGNUInline() { |
| 3608 | AttrKind = ParsedAttr::AT_GNUInline; |
| 3609 | NumArgs = 0; |
| 3610 | OptArgs = 0; |
| 3611 | HasCustomParsing = 0; |
| 3612 | IsTargetSpecific = 0; |
| 3613 | IsType = 0; |
| 3614 | IsStmt = 0; |
| 3615 | IsKnownToGCC = 1; |
| 3616 | IsSupportedByPragmaAttribute = 1; |
| 3617 | Spellings = GNUInlineSpellings; |
| 3618 | } |
| 3619 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3620 | if (!isa<FunctionDecl>(D)) { |
| 3621 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3622 | << Attr << "functions" ; |
| 3623 | return false; |
| 3624 | } |
| 3625 | return true; |
| 3626 | } |
| 3627 | |
| 3628 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3629 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3630 | } |
| 3631 | |
| 3632 | static const ParsedAttrInfoGNUInline Instance; |
| 3633 | }; |
| 3634 | const ParsedAttrInfoGNUInline ParsedAttrInfoGNUInline::Instance; |
| 3635 | static constexpr ParsedAttrInfo::Spelling GuardedBySpellings[] = { |
| 3636 | {AttributeCommonInfo::AS_GNU, "guarded_by" }, |
| 3637 | }; |
| 3638 | struct ParsedAttrInfoGuardedBy final : public ParsedAttrInfo { |
| 3639 | ParsedAttrInfoGuardedBy() { |
| 3640 | AttrKind = ParsedAttr::AT_GuardedBy; |
| 3641 | NumArgs = 1; |
| 3642 | OptArgs = 0; |
| 3643 | HasCustomParsing = 0; |
| 3644 | IsTargetSpecific = 0; |
| 3645 | IsType = 0; |
| 3646 | IsStmt = 0; |
| 3647 | IsKnownToGCC = 0; |
| 3648 | IsSupportedByPragmaAttribute = 0; |
| 3649 | Spellings = GuardedBySpellings; |
| 3650 | } |
| 3651 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3652 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
| 3653 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3654 | << Attr << "non-static data members and global variables" ; |
| 3655 | return false; |
| 3656 | } |
| 3657 | return true; |
| 3658 | } |
| 3659 | |
| 3660 | static const ParsedAttrInfoGuardedBy Instance; |
| 3661 | }; |
| 3662 | const ParsedAttrInfoGuardedBy ParsedAttrInfoGuardedBy::Instance; |
| 3663 | static constexpr ParsedAttrInfo::Spelling GuardedVarSpellings[] = { |
| 3664 | {AttributeCommonInfo::AS_GNU, "guarded_var" }, |
| 3665 | {AttributeCommonInfo::AS_CXX11, "clang::guarded_var" }, |
| 3666 | }; |
| 3667 | struct ParsedAttrInfoGuardedVar final : public ParsedAttrInfo { |
| 3668 | ParsedAttrInfoGuardedVar() { |
| 3669 | AttrKind = ParsedAttr::AT_GuardedVar; |
| 3670 | NumArgs = 0; |
| 3671 | OptArgs = 0; |
| 3672 | HasCustomParsing = 0; |
| 3673 | IsTargetSpecific = 0; |
| 3674 | IsType = 0; |
| 3675 | IsStmt = 0; |
| 3676 | IsKnownToGCC = 0; |
| 3677 | IsSupportedByPragmaAttribute = 0; |
| 3678 | Spellings = GuardedVarSpellings; |
| 3679 | } |
| 3680 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3681 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
| 3682 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3683 | << Attr << "non-static data members and global variables" ; |
| 3684 | return false; |
| 3685 | } |
| 3686 | return true; |
| 3687 | } |
| 3688 | |
| 3689 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 3690 | D->addAttr(::new (S.Context) GuardedVarAttr(S.Context, Attr)); |
| 3691 | return AttributeApplied; |
| 3692 | } |
| 3693 | |
| 3694 | static const ParsedAttrInfoGuardedVar Instance; |
| 3695 | }; |
| 3696 | const ParsedAttrInfoGuardedVar ParsedAttrInfoGuardedVar::Instance; |
| 3697 | static constexpr ParsedAttrInfo::Spelling HIPManagedSpellings[] = { |
| 3698 | {AttributeCommonInfo::AS_GNU, "managed" }, |
| 3699 | {AttributeCommonInfo::AS_Declspec, "__managed__" }, |
| 3700 | }; |
| 3701 | struct ParsedAttrInfoHIPManaged final : public ParsedAttrInfo { |
| 3702 | ParsedAttrInfoHIPManaged() { |
| 3703 | AttrKind = ParsedAttr::AT_HIPManaged; |
| 3704 | NumArgs = 0; |
| 3705 | OptArgs = 0; |
| 3706 | HasCustomParsing = 0; |
| 3707 | IsTargetSpecific = 0; |
| 3708 | IsType = 0; |
| 3709 | IsStmt = 0; |
| 3710 | IsKnownToGCC = 0; |
| 3711 | IsSupportedByPragmaAttribute = 1; |
| 3712 | Spellings = HIPManagedSpellings; |
| 3713 | } |
| 3714 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3715 | if (!isa<VarDecl>(D)) { |
| 3716 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3717 | << Attr << "variables" ; |
| 3718 | return false; |
| 3719 | } |
| 3720 | return true; |
| 3721 | } |
| 3722 | |
| 3723 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 3724 | auto &LangOpts = S.LangOpts; |
| 3725 | if (LangOpts.HIP) |
| 3726 | return true; |
| 3727 | |
| 3728 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 3729 | return false; |
| 3730 | } |
| 3731 | |
| 3732 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3733 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 3734 | } |
| 3735 | |
| 3736 | static const ParsedAttrInfoHIPManaged Instance; |
| 3737 | }; |
| 3738 | const ParsedAttrInfoHIPManaged ParsedAttrInfoHIPManaged::Instance; |
| 3739 | static constexpr ParsedAttrInfo::Spelling HotSpellings[] = { |
| 3740 | {AttributeCommonInfo::AS_GNU, "hot" }, |
| 3741 | {AttributeCommonInfo::AS_CXX11, "gnu::hot" }, |
| 3742 | {AttributeCommonInfo::AS_C2x, "gnu::hot" }, |
| 3743 | }; |
| 3744 | struct ParsedAttrInfoHot final : public ParsedAttrInfo { |
| 3745 | ParsedAttrInfoHot() { |
| 3746 | AttrKind = ParsedAttr::AT_Hot; |
| 3747 | NumArgs = 0; |
| 3748 | OptArgs = 0; |
| 3749 | HasCustomParsing = 0; |
| 3750 | IsTargetSpecific = 0; |
| 3751 | IsType = 0; |
| 3752 | IsStmt = 0; |
| 3753 | IsKnownToGCC = 1; |
| 3754 | IsSupportedByPragmaAttribute = 1; |
| 3755 | Spellings = HotSpellings; |
| 3756 | } |
| 3757 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3758 | if (!isa<FunctionDecl>(D)) { |
| 3759 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3760 | << Attr << "functions" ; |
| 3761 | return false; |
| 3762 | } |
| 3763 | return true; |
| 3764 | } |
| 3765 | |
| 3766 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3767 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3768 | } |
| 3769 | |
| 3770 | static const ParsedAttrInfoHot Instance; |
| 3771 | }; |
| 3772 | const ParsedAttrInfoHot ParsedAttrInfoHot::Instance; |
| 3773 | static constexpr ParsedAttrInfo::Spelling IBActionSpellings[] = { |
| 3774 | {AttributeCommonInfo::AS_GNU, "ibaction" }, |
| 3775 | {AttributeCommonInfo::AS_CXX11, "clang::ibaction" }, |
| 3776 | {AttributeCommonInfo::AS_C2x, "clang::ibaction" }, |
| 3777 | }; |
| 3778 | struct ParsedAttrInfoIBAction final : public ParsedAttrInfo { |
| 3779 | ParsedAttrInfoIBAction() { |
| 3780 | AttrKind = ParsedAttr::AT_IBAction; |
| 3781 | NumArgs = 0; |
| 3782 | OptArgs = 0; |
| 3783 | HasCustomParsing = 0; |
| 3784 | IsTargetSpecific = 0; |
| 3785 | IsType = 0; |
| 3786 | IsStmt = 0; |
| 3787 | IsKnownToGCC = 0; |
| 3788 | IsSupportedByPragmaAttribute = 1; |
| 3789 | Spellings = IBActionSpellings; |
| 3790 | } |
| 3791 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3792 | if (!isObjCInstanceMethod(D)) { |
| 3793 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3794 | << Attr << "Objective-C instance methods" ; |
| 3795 | return false; |
| 3796 | } |
| 3797 | return true; |
| 3798 | } |
| 3799 | |
| 3800 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3801 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method_is_instance, /*IsSupported=*/LangOpts.ObjC)); |
| 3802 | } |
| 3803 | |
| 3804 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 3805 | D->addAttr(::new (S.Context) IBActionAttr(S.Context, Attr)); |
| 3806 | return AttributeApplied; |
| 3807 | } |
| 3808 | |
| 3809 | static const ParsedAttrInfoIBAction Instance; |
| 3810 | }; |
| 3811 | const ParsedAttrInfoIBAction ParsedAttrInfoIBAction::Instance; |
| 3812 | static constexpr ParsedAttrInfo::Spelling IBOutletSpellings[] = { |
| 3813 | {AttributeCommonInfo::AS_GNU, "iboutlet" }, |
| 3814 | {AttributeCommonInfo::AS_CXX11, "clang::iboutlet" }, |
| 3815 | {AttributeCommonInfo::AS_C2x, "clang::iboutlet" }, |
| 3816 | }; |
| 3817 | struct ParsedAttrInfoIBOutlet final : public ParsedAttrInfo { |
| 3818 | ParsedAttrInfoIBOutlet() { |
| 3819 | AttrKind = ParsedAttr::AT_IBOutlet; |
| 3820 | NumArgs = 0; |
| 3821 | OptArgs = 0; |
| 3822 | HasCustomParsing = 0; |
| 3823 | IsTargetSpecific = 0; |
| 3824 | IsType = 0; |
| 3825 | IsStmt = 0; |
| 3826 | IsKnownToGCC = 0; |
| 3827 | IsSupportedByPragmaAttribute = 0; |
| 3828 | Spellings = IBOutletSpellings; |
| 3829 | } |
| 3830 | static const ParsedAttrInfoIBOutlet Instance; |
| 3831 | }; |
| 3832 | const ParsedAttrInfoIBOutlet ParsedAttrInfoIBOutlet::Instance; |
| 3833 | static constexpr ParsedAttrInfo::Spelling IBOutletCollectionSpellings[] = { |
| 3834 | {AttributeCommonInfo::AS_GNU, "iboutletcollection" }, |
| 3835 | {AttributeCommonInfo::AS_CXX11, "clang::iboutletcollection" }, |
| 3836 | {AttributeCommonInfo::AS_C2x, "clang::iboutletcollection" }, |
| 3837 | }; |
| 3838 | struct ParsedAttrInfoIBOutletCollection final : public ParsedAttrInfo { |
| 3839 | ParsedAttrInfoIBOutletCollection() { |
| 3840 | AttrKind = ParsedAttr::AT_IBOutletCollection; |
| 3841 | NumArgs = 0; |
| 3842 | OptArgs = 1; |
| 3843 | HasCustomParsing = 0; |
| 3844 | IsTargetSpecific = 0; |
| 3845 | IsType = 0; |
| 3846 | IsStmt = 0; |
| 3847 | IsKnownToGCC = 0; |
| 3848 | IsSupportedByPragmaAttribute = 0; |
| 3849 | Spellings = IBOutletCollectionSpellings; |
| 3850 | } |
| 3851 | static const ParsedAttrInfoIBOutletCollection Instance; |
| 3852 | }; |
| 3853 | const ParsedAttrInfoIBOutletCollection ParsedAttrInfoIBOutletCollection::Instance; |
| 3854 | static constexpr ParsedAttrInfo::Spelling IFuncSpellings[] = { |
| 3855 | {AttributeCommonInfo::AS_GNU, "ifunc" }, |
| 3856 | {AttributeCommonInfo::AS_CXX11, "gnu::ifunc" }, |
| 3857 | {AttributeCommonInfo::AS_C2x, "gnu::ifunc" }, |
| 3858 | }; |
| 3859 | struct ParsedAttrInfoIFunc final : public ParsedAttrInfo { |
| 3860 | ParsedAttrInfoIFunc() { |
| 3861 | AttrKind = ParsedAttr::AT_IFunc; |
| 3862 | NumArgs = 1; |
| 3863 | OptArgs = 0; |
| 3864 | HasCustomParsing = 0; |
| 3865 | IsTargetSpecific = 1; |
| 3866 | IsType = 0; |
| 3867 | IsStmt = 0; |
| 3868 | IsKnownToGCC = 1; |
| 3869 | IsSupportedByPragmaAttribute = 1; |
| 3870 | Spellings = IFuncSpellings; |
| 3871 | } |
| 3872 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3873 | if (!isa<FunctionDecl>(D)) { |
| 3874 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3875 | << Attr << "functions" ; |
| 3876 | return false; |
| 3877 | } |
| 3878 | return true; |
| 3879 | } |
| 3880 | |
| 3881 | bool existsInTarget(const TargetInfo &Target) const override { |
| 3882 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 3883 | return true && (T.getObjectFormat() == llvm::Triple::ELF); |
| 3884 | } |
| 3885 | |
| 3886 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3887 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3888 | } |
| 3889 | |
| 3890 | static const ParsedAttrInfoIFunc Instance; |
| 3891 | }; |
| 3892 | const ParsedAttrInfoIFunc ParsedAttrInfoIFunc::Instance; |
| 3893 | static constexpr ParsedAttrInfo::Spelling InitPrioritySpellings[] = { |
| 3894 | {AttributeCommonInfo::AS_GNU, "init_priority" }, |
| 3895 | {AttributeCommonInfo::AS_CXX11, "gnu::init_priority" }, |
| 3896 | }; |
| 3897 | struct ParsedAttrInfoInitPriority final : public ParsedAttrInfo { |
| 3898 | ParsedAttrInfoInitPriority() { |
| 3899 | AttrKind = ParsedAttr::AT_InitPriority; |
| 3900 | NumArgs = 1; |
| 3901 | OptArgs = 0; |
| 3902 | HasCustomParsing = 0; |
| 3903 | IsTargetSpecific = 1; |
| 3904 | IsType = 0; |
| 3905 | IsStmt = 0; |
| 3906 | IsKnownToGCC = 1; |
| 3907 | IsSupportedByPragmaAttribute = 1; |
| 3908 | Spellings = InitPrioritySpellings; |
| 3909 | } |
| 3910 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3911 | if (!isa<VarDecl>(D)) { |
| 3912 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 3913 | << Attr << "variables" ; |
| 3914 | return false; |
| 3915 | } |
| 3916 | return true; |
| 3917 | } |
| 3918 | |
| 3919 | bool existsInTarget(const TargetInfo &Target) const override { |
| 3920 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 3921 | return true && ( !Target.getTriple().isOSzOS() ); |
| 3922 | } |
| 3923 | |
| 3924 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3925 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 3926 | } |
| 3927 | |
| 3928 | static const ParsedAttrInfoInitPriority Instance; |
| 3929 | }; |
| 3930 | const ParsedAttrInfoInitPriority ParsedAttrInfoInitPriority::Instance; |
| 3931 | static constexpr ParsedAttrInfo::Spelling IntelOclBiccSpellings[] = { |
| 3932 | {AttributeCommonInfo::AS_GNU, "intel_ocl_bicc" }, |
| 3933 | {AttributeCommonInfo::AS_CXX11, "clang::intel_ocl_bicc" }, |
| 3934 | }; |
| 3935 | struct ParsedAttrInfoIntelOclBicc final : public ParsedAttrInfo { |
| 3936 | ParsedAttrInfoIntelOclBicc() { |
| 3937 | AttrKind = ParsedAttr::AT_IntelOclBicc; |
| 3938 | NumArgs = 0; |
| 3939 | OptArgs = 0; |
| 3940 | HasCustomParsing = 0; |
| 3941 | IsTargetSpecific = 0; |
| 3942 | IsType = 1; |
| 3943 | IsStmt = 0; |
| 3944 | IsKnownToGCC = 0; |
| 3945 | IsSupportedByPragmaAttribute = 0; |
| 3946 | Spellings = IntelOclBiccSpellings; |
| 3947 | } |
| 3948 | static const ParsedAttrInfoIntelOclBicc Instance; |
| 3949 | }; |
| 3950 | const ParsedAttrInfoIntelOclBicc ParsedAttrInfoIntelOclBicc::Instance; |
| 3951 | static constexpr ParsedAttrInfo::Spelling InternalLinkageSpellings[] = { |
| 3952 | {AttributeCommonInfo::AS_GNU, "internal_linkage" }, |
| 3953 | {AttributeCommonInfo::AS_CXX11, "clang::internal_linkage" }, |
| 3954 | {AttributeCommonInfo::AS_C2x, "clang::internal_linkage" }, |
| 3955 | }; |
| 3956 | struct ParsedAttrInfoInternalLinkage final : public ParsedAttrInfo { |
| 3957 | ParsedAttrInfoInternalLinkage() { |
| 3958 | AttrKind = ParsedAttr::AT_InternalLinkage; |
| 3959 | NumArgs = 0; |
| 3960 | OptArgs = 0; |
| 3961 | HasCustomParsing = 0; |
| 3962 | IsTargetSpecific = 0; |
| 3963 | IsType = 0; |
| 3964 | IsStmt = 0; |
| 3965 | IsKnownToGCC = 0; |
| 3966 | IsSupportedByPragmaAttribute = 1; |
| 3967 | Spellings = InternalLinkageSpellings; |
| 3968 | } |
| 3969 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 3970 | if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D)) { |
| 3971 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 3972 | << Attr << "variables, functions, and classes" ; |
| 3973 | return false; |
| 3974 | } |
| 3975 | return true; |
| 3976 | } |
| 3977 | |
| 3978 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 3979 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 3980 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 3981 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 3982 | } |
| 3983 | |
| 3984 | static const ParsedAttrInfoInternalLinkage Instance; |
| 3985 | }; |
| 3986 | const ParsedAttrInfoInternalLinkage ParsedAttrInfoInternalLinkage::Instance; |
| 3987 | static constexpr ParsedAttrInfo::Spelling LTOVisibilityPublicSpellings[] = { |
| 3988 | {AttributeCommonInfo::AS_GNU, "lto_visibility_public" }, |
| 3989 | {AttributeCommonInfo::AS_CXX11, "clang::lto_visibility_public" }, |
| 3990 | {AttributeCommonInfo::AS_C2x, "clang::lto_visibility_public" }, |
| 3991 | }; |
| 3992 | struct ParsedAttrInfoLTOVisibilityPublic final : public ParsedAttrInfo { |
| 3993 | ParsedAttrInfoLTOVisibilityPublic() { |
| 3994 | AttrKind = ParsedAttr::AT_LTOVisibilityPublic; |
| 3995 | NumArgs = 0; |
| 3996 | OptArgs = 0; |
| 3997 | HasCustomParsing = 0; |
| 3998 | IsTargetSpecific = 0; |
| 3999 | IsType = 0; |
| 4000 | IsStmt = 0; |
| 4001 | IsKnownToGCC = 0; |
| 4002 | IsSupportedByPragmaAttribute = 1; |
| 4003 | Spellings = LTOVisibilityPublicSpellings; |
| 4004 | } |
| 4005 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4006 | if (!isa<RecordDecl>(D)) { |
| 4007 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4008 | << Attr << "structs, unions, and classes" ; |
| 4009 | return false; |
| 4010 | } |
| 4011 | return true; |
| 4012 | } |
| 4013 | |
| 4014 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4015 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 4016 | } |
| 4017 | |
| 4018 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 4019 | D->addAttr(::new (S.Context) LTOVisibilityPublicAttr(S.Context, Attr)); |
| 4020 | return AttributeApplied; |
| 4021 | } |
| 4022 | |
| 4023 | static const ParsedAttrInfoLTOVisibilityPublic Instance; |
| 4024 | }; |
| 4025 | const ParsedAttrInfoLTOVisibilityPublic ParsedAttrInfoLTOVisibilityPublic::Instance; |
| 4026 | static constexpr ParsedAttrInfo::Spelling LayoutVersionSpellings[] = { |
| 4027 | {AttributeCommonInfo::AS_Declspec, "layout_version" }, |
| 4028 | }; |
| 4029 | struct ParsedAttrInfoLayoutVersion final : public ParsedAttrInfo { |
| 4030 | ParsedAttrInfoLayoutVersion() { |
| 4031 | AttrKind = ParsedAttr::AT_LayoutVersion; |
| 4032 | NumArgs = 1; |
| 4033 | OptArgs = 0; |
| 4034 | HasCustomParsing = 0; |
| 4035 | IsTargetSpecific = 1; |
| 4036 | IsType = 0; |
| 4037 | IsStmt = 0; |
| 4038 | IsKnownToGCC = 0; |
| 4039 | IsSupportedByPragmaAttribute = 0; |
| 4040 | Spellings = LayoutVersionSpellings; |
| 4041 | } |
| 4042 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4043 | if (!isa<CXXRecordDecl>(D)) { |
| 4044 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4045 | << Attr << "classes" ; |
| 4046 | return false; |
| 4047 | } |
| 4048 | return true; |
| 4049 | } |
| 4050 | |
| 4051 | bool existsInTarget(const TargetInfo &Target) const override { |
| 4052 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 4053 | return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64 || T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::aarch64) && ( Target.getCXXABI().isMicrosoft() ); |
| 4054 | } |
| 4055 | |
| 4056 | static const ParsedAttrInfoLayoutVersion Instance; |
| 4057 | }; |
| 4058 | const ParsedAttrInfoLayoutVersion ParsedAttrInfoLayoutVersion::Instance; |
| 4059 | static constexpr ParsedAttrInfo::Spelling LeafSpellings[] = { |
| 4060 | {AttributeCommonInfo::AS_GNU, "leaf" }, |
| 4061 | {AttributeCommonInfo::AS_CXX11, "gnu::leaf" }, |
| 4062 | {AttributeCommonInfo::AS_C2x, "gnu::leaf" }, |
| 4063 | }; |
| 4064 | struct ParsedAttrInfoLeaf final : public ParsedAttrInfo { |
| 4065 | ParsedAttrInfoLeaf() { |
| 4066 | AttrKind = ParsedAttr::AT_Leaf; |
| 4067 | NumArgs = 0; |
| 4068 | OptArgs = 0; |
| 4069 | HasCustomParsing = 0; |
| 4070 | IsTargetSpecific = 0; |
| 4071 | IsType = 0; |
| 4072 | IsStmt = 0; |
| 4073 | IsKnownToGCC = 1; |
| 4074 | IsSupportedByPragmaAttribute = 1; |
| 4075 | Spellings = LeafSpellings; |
| 4076 | } |
| 4077 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4078 | if (!isa<FunctionDecl>(D)) { |
| 4079 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4080 | << Attr << "functions" ; |
| 4081 | return false; |
| 4082 | } |
| 4083 | return true; |
| 4084 | } |
| 4085 | |
| 4086 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4087 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 4088 | } |
| 4089 | |
| 4090 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 4091 | D->addAttr(::new (S.Context) LeafAttr(S.Context, Attr)); |
| 4092 | return AttributeApplied; |
| 4093 | } |
| 4094 | |
| 4095 | static const ParsedAttrInfoLeaf Instance; |
| 4096 | }; |
| 4097 | const ParsedAttrInfoLeaf ParsedAttrInfoLeaf::Instance; |
| 4098 | static constexpr ParsedAttrInfo::Spelling LifetimeBoundSpellings[] = { |
| 4099 | {AttributeCommonInfo::AS_GNU, "lifetimebound" }, |
| 4100 | {AttributeCommonInfo::AS_CXX11, "clang::lifetimebound" }, |
| 4101 | }; |
| 4102 | struct ParsedAttrInfoLifetimeBound final : public ParsedAttrInfo { |
| 4103 | ParsedAttrInfoLifetimeBound() { |
| 4104 | AttrKind = ParsedAttr::AT_LifetimeBound; |
| 4105 | NumArgs = 0; |
| 4106 | OptArgs = 0; |
| 4107 | HasCustomParsing = 0; |
| 4108 | IsTargetSpecific = 0; |
| 4109 | IsType = 1; |
| 4110 | IsStmt = 0; |
| 4111 | IsKnownToGCC = 0; |
| 4112 | IsSupportedByPragmaAttribute = 0; |
| 4113 | Spellings = LifetimeBoundSpellings; |
| 4114 | } |
| 4115 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4116 | if (!isa<ParmVarDecl>(D) && !isImplicitObjectParameter(D)) { |
| 4117 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 4118 | << Attr << "parameters and implicit object parameters" ; |
| 4119 | return false; |
| 4120 | } |
| 4121 | return true; |
| 4122 | } |
| 4123 | |
| 4124 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 4125 | auto &LangOpts = S.LangOpts; |
| 4126 | if (LangOpts.CPlusPlus) |
| 4127 | return true; |
| 4128 | |
| 4129 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 4130 | return false; |
| 4131 | } |
| 4132 | |
| 4133 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 4134 | D->addAttr(::new (S.Context) LifetimeBoundAttr(S.Context, Attr)); |
| 4135 | return AttributeApplied; |
| 4136 | } |
| 4137 | |
| 4138 | static const ParsedAttrInfoLifetimeBound Instance; |
| 4139 | }; |
| 4140 | const ParsedAttrInfoLifetimeBound ParsedAttrInfoLifetimeBound::Instance; |
| 4141 | static constexpr ParsedAttrInfo::Spelling LikelySpellings[] = { |
| 4142 | {AttributeCommonInfo::AS_CXX11, "likely" }, |
| 4143 | {AttributeCommonInfo::AS_C2x, "clang::likely" }, |
| 4144 | }; |
| 4145 | struct ParsedAttrInfoLikely final : public ParsedAttrInfo { |
| 4146 | ParsedAttrInfoLikely() { |
| 4147 | AttrKind = ParsedAttr::AT_Likely; |
| 4148 | NumArgs = 0; |
| 4149 | OptArgs = 0; |
| 4150 | HasCustomParsing = 0; |
| 4151 | IsTargetSpecific = 0; |
| 4152 | IsType = 0; |
| 4153 | IsStmt = 1; |
| 4154 | IsKnownToGCC = 0; |
| 4155 | IsSupportedByPragmaAttribute = 0; |
| 4156 | Spellings = LikelySpellings; |
| 4157 | } |
| 4158 | static const ParsedAttrInfoLikely Instance; |
| 4159 | }; |
| 4160 | const ParsedAttrInfoLikely ParsedAttrInfoLikely::Instance; |
| 4161 | static constexpr ParsedAttrInfo::Spelling LoaderUninitializedSpellings[] = { |
| 4162 | {AttributeCommonInfo::AS_GNU, "loader_uninitialized" }, |
| 4163 | {AttributeCommonInfo::AS_CXX11, "clang::loader_uninitialized" }, |
| 4164 | {AttributeCommonInfo::AS_C2x, "clang::loader_uninitialized" }, |
| 4165 | }; |
| 4166 | struct ParsedAttrInfoLoaderUninitialized final : public ParsedAttrInfo { |
| 4167 | ParsedAttrInfoLoaderUninitialized() { |
| 4168 | AttrKind = ParsedAttr::AT_LoaderUninitialized; |
| 4169 | NumArgs = 0; |
| 4170 | OptArgs = 0; |
| 4171 | HasCustomParsing = 0; |
| 4172 | IsTargetSpecific = 0; |
| 4173 | IsType = 0; |
| 4174 | IsStmt = 0; |
| 4175 | IsKnownToGCC = 0; |
| 4176 | IsSupportedByPragmaAttribute = 1; |
| 4177 | Spellings = LoaderUninitializedSpellings; |
| 4178 | } |
| 4179 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4180 | if (!isGlobalVar(D)) { |
| 4181 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4182 | << Attr << "global variables" ; |
| 4183 | return false; |
| 4184 | } |
| 4185 | return true; |
| 4186 | } |
| 4187 | |
| 4188 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4189 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
| 4190 | } |
| 4191 | |
| 4192 | static const ParsedAttrInfoLoaderUninitialized Instance; |
| 4193 | }; |
| 4194 | const ParsedAttrInfoLoaderUninitialized ParsedAttrInfoLoaderUninitialized::Instance; |
| 4195 | static constexpr ParsedAttrInfo::Spelling LockReturnedSpellings[] = { |
| 4196 | {AttributeCommonInfo::AS_GNU, "lock_returned" }, |
| 4197 | }; |
| 4198 | struct ParsedAttrInfoLockReturned final : public ParsedAttrInfo { |
| 4199 | ParsedAttrInfoLockReturned() { |
| 4200 | AttrKind = ParsedAttr::AT_LockReturned; |
| 4201 | NumArgs = 1; |
| 4202 | OptArgs = 0; |
| 4203 | HasCustomParsing = 0; |
| 4204 | IsTargetSpecific = 0; |
| 4205 | IsType = 0; |
| 4206 | IsStmt = 0; |
| 4207 | IsKnownToGCC = 0; |
| 4208 | IsSupportedByPragmaAttribute = 0; |
| 4209 | Spellings = LockReturnedSpellings; |
| 4210 | } |
| 4211 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4212 | if (!isa<FunctionDecl>(D)) { |
| 4213 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4214 | << Attr << "functions" ; |
| 4215 | return false; |
| 4216 | } |
| 4217 | return true; |
| 4218 | } |
| 4219 | |
| 4220 | static const ParsedAttrInfoLockReturned Instance; |
| 4221 | }; |
| 4222 | const ParsedAttrInfoLockReturned ParsedAttrInfoLockReturned::Instance; |
| 4223 | static constexpr ParsedAttrInfo::Spelling LockableSpellings[] = { |
| 4224 | {AttributeCommonInfo::AS_GNU, "lockable" }, |
| 4225 | }; |
| 4226 | struct ParsedAttrInfoLockable final : public ParsedAttrInfo { |
| 4227 | ParsedAttrInfoLockable() { |
| 4228 | AttrKind = ParsedAttr::AT_Lockable; |
| 4229 | NumArgs = 0; |
| 4230 | OptArgs = 0; |
| 4231 | HasCustomParsing = 0; |
| 4232 | IsTargetSpecific = 0; |
| 4233 | IsType = 0; |
| 4234 | IsStmt = 0; |
| 4235 | IsKnownToGCC = 0; |
| 4236 | IsSupportedByPragmaAttribute = 1; |
| 4237 | Spellings = LockableSpellings; |
| 4238 | } |
| 4239 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4240 | if (!isa<RecordDecl>(D)) { |
| 4241 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4242 | << Attr << "structs, unions, and classes" ; |
| 4243 | return false; |
| 4244 | } |
| 4245 | return true; |
| 4246 | } |
| 4247 | |
| 4248 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4249 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 4250 | } |
| 4251 | |
| 4252 | static const ParsedAttrInfoLockable Instance; |
| 4253 | }; |
| 4254 | const ParsedAttrInfoLockable ParsedAttrInfoLockable::Instance; |
| 4255 | static constexpr ParsedAttrInfo::Spelling LocksExcludedSpellings[] = { |
| 4256 | {AttributeCommonInfo::AS_GNU, "locks_excluded" }, |
| 4257 | }; |
| 4258 | struct ParsedAttrInfoLocksExcluded final : public ParsedAttrInfo { |
| 4259 | ParsedAttrInfoLocksExcluded() { |
| 4260 | AttrKind = ParsedAttr::AT_LocksExcluded; |
| 4261 | NumArgs = 0; |
| 4262 | OptArgs = 15; |
| 4263 | HasCustomParsing = 0; |
| 4264 | IsTargetSpecific = 0; |
| 4265 | IsType = 0; |
| 4266 | IsStmt = 0; |
| 4267 | IsKnownToGCC = 0; |
| 4268 | IsSupportedByPragmaAttribute = 0; |
| 4269 | Spellings = LocksExcludedSpellings; |
| 4270 | } |
| 4271 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4272 | if (!isa<FunctionDecl>(D)) { |
| 4273 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4274 | << Attr << "functions" ; |
| 4275 | return false; |
| 4276 | } |
| 4277 | return true; |
| 4278 | } |
| 4279 | |
| 4280 | static const ParsedAttrInfoLocksExcluded Instance; |
| 4281 | }; |
| 4282 | const ParsedAttrInfoLocksExcluded ParsedAttrInfoLocksExcluded::Instance; |
| 4283 | static constexpr ParsedAttrInfo::Spelling LoopHintSpellings[] = { |
| 4284 | {AttributeCommonInfo::AS_Pragma, "clang::loop" }, |
| 4285 | {AttributeCommonInfo::AS_Pragma, "unroll" }, |
| 4286 | {AttributeCommonInfo::AS_Pragma, "nounroll" }, |
| 4287 | {AttributeCommonInfo::AS_Pragma, "unroll_and_jam" }, |
| 4288 | {AttributeCommonInfo::AS_Pragma, "nounroll_and_jam" }, |
| 4289 | }; |
| 4290 | struct ParsedAttrInfoLoopHint final : public ParsedAttrInfo { |
| 4291 | ParsedAttrInfoLoopHint() { |
| 4292 | AttrKind = ParsedAttr::AT_LoopHint; |
| 4293 | NumArgs = 3; |
| 4294 | OptArgs = 0; |
| 4295 | HasCustomParsing = 0; |
| 4296 | IsTargetSpecific = 0; |
| 4297 | IsType = 0; |
| 4298 | IsStmt = 0; |
| 4299 | IsKnownToGCC = 0; |
| 4300 | IsSupportedByPragmaAttribute = 0; |
| 4301 | Spellings = LoopHintSpellings; |
| 4302 | } |
| 4303 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 4304 | enum Spelling { |
| 4305 | Pragma_clang_loop = 0, |
| 4306 | Pragma_unroll = 1, |
| 4307 | Pragma_nounroll = 2, |
| 4308 | Pragma_unroll_and_jam = 3, |
| 4309 | Pragma_nounroll_and_jam = 4, |
| 4310 | SpellingNotCalculated = 15 |
| 4311 | |
| 4312 | }; |
| 4313 | |
| 4314 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 4315 | switch (Idx) { |
| 4316 | default: llvm_unreachable("Unknown spelling list index" ); |
| 4317 | case 0: return Pragma_clang_loop; |
| 4318 | case 1: return Pragma_unroll; |
| 4319 | case 2: return Pragma_nounroll; |
| 4320 | case 3: return Pragma_unroll_and_jam; |
| 4321 | case 4: return Pragma_nounroll_and_jam; |
| 4322 | } |
| 4323 | } |
| 4324 | |
| 4325 | static const ParsedAttrInfoLoopHint Instance; |
| 4326 | }; |
| 4327 | const ParsedAttrInfoLoopHint ParsedAttrInfoLoopHint::Instance; |
| 4328 | static constexpr ParsedAttrInfo::Spelling MIGServerRoutineSpellings[] = { |
| 4329 | {AttributeCommonInfo::AS_GNU, "mig_server_routine" }, |
| 4330 | {AttributeCommonInfo::AS_CXX11, "clang::mig_server_routine" }, |
| 4331 | {AttributeCommonInfo::AS_C2x, "clang::mig_server_routine" }, |
| 4332 | }; |
| 4333 | struct ParsedAttrInfoMIGServerRoutine final : public ParsedAttrInfo { |
| 4334 | ParsedAttrInfoMIGServerRoutine() { |
| 4335 | AttrKind = ParsedAttr::AT_MIGServerRoutine; |
| 4336 | NumArgs = 0; |
| 4337 | OptArgs = 0; |
| 4338 | HasCustomParsing = 0; |
| 4339 | IsTargetSpecific = 0; |
| 4340 | IsType = 0; |
| 4341 | IsStmt = 0; |
| 4342 | IsKnownToGCC = 0; |
| 4343 | IsSupportedByPragmaAttribute = 1; |
| 4344 | Spellings = MIGServerRoutineSpellings; |
| 4345 | } |
| 4346 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4347 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<BlockDecl>(D)) { |
| 4348 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4349 | << Attr << "functions, Objective-C methods, and blocks" ; |
| 4350 | return false; |
| 4351 | } |
| 4352 | return true; |
| 4353 | } |
| 4354 | |
| 4355 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4356 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 4357 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 4358 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_block, /*IsSupported=*/LangOpts.Blocks)); |
| 4359 | } |
| 4360 | |
| 4361 | static const ParsedAttrInfoMIGServerRoutine Instance; |
| 4362 | }; |
| 4363 | const ParsedAttrInfoMIGServerRoutine ParsedAttrInfoMIGServerRoutine::Instance; |
| 4364 | static constexpr ParsedAttrInfo::Spelling MSABISpellings[] = { |
| 4365 | {AttributeCommonInfo::AS_GNU, "ms_abi" }, |
| 4366 | {AttributeCommonInfo::AS_CXX11, "gnu::ms_abi" }, |
| 4367 | {AttributeCommonInfo::AS_C2x, "gnu::ms_abi" }, |
| 4368 | }; |
| 4369 | struct ParsedAttrInfoMSABI final : public ParsedAttrInfo { |
| 4370 | ParsedAttrInfoMSABI() { |
| 4371 | AttrKind = ParsedAttr::AT_MSABI; |
| 4372 | NumArgs = 0; |
| 4373 | OptArgs = 0; |
| 4374 | HasCustomParsing = 0; |
| 4375 | IsTargetSpecific = 0; |
| 4376 | IsType = 1; |
| 4377 | IsStmt = 0; |
| 4378 | IsKnownToGCC = 1; |
| 4379 | IsSupportedByPragmaAttribute = 0; |
| 4380 | Spellings = MSABISpellings; |
| 4381 | } |
| 4382 | static const ParsedAttrInfoMSABI Instance; |
| 4383 | }; |
| 4384 | const ParsedAttrInfoMSABI ParsedAttrInfoMSABI::Instance; |
| 4385 | static constexpr ParsedAttrInfo::Spelling MSAllocatorSpellings[] = { |
| 4386 | {AttributeCommonInfo::AS_Declspec, "allocator" }, |
| 4387 | }; |
| 4388 | struct ParsedAttrInfoMSAllocator final : public ParsedAttrInfo { |
| 4389 | ParsedAttrInfoMSAllocator() { |
| 4390 | AttrKind = ParsedAttr::AT_MSAllocator; |
| 4391 | NumArgs = 0; |
| 4392 | OptArgs = 0; |
| 4393 | HasCustomParsing = 0; |
| 4394 | IsTargetSpecific = 0; |
| 4395 | IsType = 0; |
| 4396 | IsStmt = 0; |
| 4397 | IsKnownToGCC = 0; |
| 4398 | IsSupportedByPragmaAttribute = 0; |
| 4399 | Spellings = MSAllocatorSpellings; |
| 4400 | } |
| 4401 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4402 | if (!isa<FunctionDecl>(D)) { |
| 4403 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4404 | << Attr << "functions" ; |
| 4405 | return false; |
| 4406 | } |
| 4407 | return true; |
| 4408 | } |
| 4409 | |
| 4410 | static const ParsedAttrInfoMSAllocator Instance; |
| 4411 | }; |
| 4412 | const ParsedAttrInfoMSAllocator ParsedAttrInfoMSAllocator::Instance; |
| 4413 | static constexpr ParsedAttrInfo::Spelling MSInheritanceSpellings[] = { |
| 4414 | {AttributeCommonInfo::AS_Keyword, "__single_inheritance" }, |
| 4415 | {AttributeCommonInfo::AS_Keyword, "__multiple_inheritance" }, |
| 4416 | {AttributeCommonInfo::AS_Keyword, "__virtual_inheritance" }, |
| 4417 | {AttributeCommonInfo::AS_Keyword, "__unspecified_inheritance" }, |
| 4418 | }; |
| 4419 | struct ParsedAttrInfoMSInheritance final : public ParsedAttrInfo { |
| 4420 | ParsedAttrInfoMSInheritance() { |
| 4421 | AttrKind = ParsedAttr::AT_MSInheritance; |
| 4422 | NumArgs = 0; |
| 4423 | OptArgs = 0; |
| 4424 | HasCustomParsing = 0; |
| 4425 | IsTargetSpecific = 0; |
| 4426 | IsType = 0; |
| 4427 | IsStmt = 0; |
| 4428 | IsKnownToGCC = 0; |
| 4429 | IsSupportedByPragmaAttribute = 0; |
| 4430 | Spellings = MSInheritanceSpellings; |
| 4431 | } |
| 4432 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 4433 | auto &LangOpts = S.LangOpts; |
| 4434 | if (LangOpts.MicrosoftExt) |
| 4435 | return true; |
| 4436 | |
| 4437 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 4438 | return false; |
| 4439 | } |
| 4440 | |
| 4441 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 4442 | enum Spelling { |
| 4443 | Keyword_single_inheritance = 0, |
| 4444 | Keyword_multiple_inheritance = 1, |
| 4445 | Keyword_virtual_inheritance = 2, |
| 4446 | Keyword_unspecified_inheritance = 3, |
| 4447 | SpellingNotCalculated = 15 |
| 4448 | |
| 4449 | }; |
| 4450 | |
| 4451 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 4452 | switch (Idx) { |
| 4453 | default: llvm_unreachable("Unknown spelling list index" ); |
| 4454 | case 0: return Keyword_single_inheritance; |
| 4455 | case 1: return Keyword_multiple_inheritance; |
| 4456 | case 2: return Keyword_virtual_inheritance; |
| 4457 | case 3: return Keyword_unspecified_inheritance; |
| 4458 | } |
| 4459 | } |
| 4460 | |
| 4461 | static const ParsedAttrInfoMSInheritance Instance; |
| 4462 | }; |
| 4463 | const ParsedAttrInfoMSInheritance ParsedAttrInfoMSInheritance::Instance; |
| 4464 | static constexpr ParsedAttrInfo::Spelling MSNoVTableSpellings[] = { |
| 4465 | {AttributeCommonInfo::AS_Declspec, "novtable" }, |
| 4466 | }; |
| 4467 | struct ParsedAttrInfoMSNoVTable final : public ParsedAttrInfo { |
| 4468 | ParsedAttrInfoMSNoVTable() { |
| 4469 | AttrKind = ParsedAttr::AT_MSNoVTable; |
| 4470 | NumArgs = 0; |
| 4471 | OptArgs = 0; |
| 4472 | HasCustomParsing = 0; |
| 4473 | IsTargetSpecific = 1; |
| 4474 | IsType = 0; |
| 4475 | IsStmt = 0; |
| 4476 | IsKnownToGCC = 0; |
| 4477 | IsSupportedByPragmaAttribute = 0; |
| 4478 | Spellings = MSNoVTableSpellings; |
| 4479 | } |
| 4480 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4481 | if (!isa<CXXRecordDecl>(D)) { |
| 4482 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4483 | << Attr << "classes" ; |
| 4484 | return false; |
| 4485 | } |
| 4486 | return true; |
| 4487 | } |
| 4488 | |
| 4489 | bool existsInTarget(const TargetInfo &Target) const override { |
| 4490 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 4491 | return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64 || T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::aarch64) && ( Target.getCXXABI().isMicrosoft() ); |
| 4492 | } |
| 4493 | |
| 4494 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 4495 | D->addAttr(::new (S.Context) MSNoVTableAttr(S.Context, Attr)); |
| 4496 | return AttributeApplied; |
| 4497 | } |
| 4498 | |
| 4499 | static const ParsedAttrInfoMSNoVTable Instance; |
| 4500 | }; |
| 4501 | const ParsedAttrInfoMSNoVTable ParsedAttrInfoMSNoVTable::Instance; |
| 4502 | static constexpr ParsedAttrInfo::Spelling MSStructSpellings[] = { |
| 4503 | {AttributeCommonInfo::AS_GNU, "ms_struct" }, |
| 4504 | {AttributeCommonInfo::AS_CXX11, "gnu::ms_struct" }, |
| 4505 | {AttributeCommonInfo::AS_C2x, "gnu::ms_struct" }, |
| 4506 | }; |
| 4507 | struct ParsedAttrInfoMSStruct final : public ParsedAttrInfo { |
| 4508 | ParsedAttrInfoMSStruct() { |
| 4509 | AttrKind = ParsedAttr::AT_MSStruct; |
| 4510 | NumArgs = 0; |
| 4511 | OptArgs = 0; |
| 4512 | HasCustomParsing = 0; |
| 4513 | IsTargetSpecific = 0; |
| 4514 | IsType = 0; |
| 4515 | IsStmt = 0; |
| 4516 | IsKnownToGCC = 1; |
| 4517 | IsSupportedByPragmaAttribute = 1; |
| 4518 | Spellings = MSStructSpellings; |
| 4519 | } |
| 4520 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4521 | if (!isa<RecordDecl>(D)) { |
| 4522 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4523 | << Attr << "structs, unions, and classes" ; |
| 4524 | return false; |
| 4525 | } |
| 4526 | return true; |
| 4527 | } |
| 4528 | |
| 4529 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4530 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 4531 | } |
| 4532 | |
| 4533 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 4534 | D->addAttr(::new (S.Context) MSStructAttr(S.Context, Attr)); |
| 4535 | return AttributeApplied; |
| 4536 | } |
| 4537 | |
| 4538 | static const ParsedAttrInfoMSStruct Instance; |
| 4539 | }; |
| 4540 | const ParsedAttrInfoMSStruct ParsedAttrInfoMSStruct::Instance; |
| 4541 | static constexpr ParsedAttrInfo::Spelling MatrixTypeSpellings[] = { |
| 4542 | {AttributeCommonInfo::AS_GNU, "matrix_type" }, |
| 4543 | {AttributeCommonInfo::AS_CXX11, "clang::matrix_type" }, |
| 4544 | {AttributeCommonInfo::AS_C2x, "clang::matrix_type" }, |
| 4545 | }; |
| 4546 | struct ParsedAttrInfoMatrixType final : public ParsedAttrInfo { |
| 4547 | ParsedAttrInfoMatrixType() { |
| 4548 | AttrKind = ParsedAttr::AT_MatrixType; |
| 4549 | NumArgs = 2; |
| 4550 | OptArgs = 0; |
| 4551 | HasCustomParsing = 0; |
| 4552 | IsTargetSpecific = 0; |
| 4553 | IsType = 1; |
| 4554 | IsStmt = 0; |
| 4555 | IsKnownToGCC = 0; |
| 4556 | IsSupportedByPragmaAttribute = 0; |
| 4557 | Spellings = MatrixTypeSpellings; |
| 4558 | } |
| 4559 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4560 | if (!isa<TypedefNameDecl>(D)) { |
| 4561 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 4562 | << Attr << "typedefs" ; |
| 4563 | return false; |
| 4564 | } |
| 4565 | return true; |
| 4566 | } |
| 4567 | |
| 4568 | static const ParsedAttrInfoMatrixType Instance; |
| 4569 | }; |
| 4570 | const ParsedAttrInfoMatrixType ParsedAttrInfoMatrixType::Instance; |
| 4571 | static constexpr ParsedAttrInfo::Spelling MayAliasSpellings[] = { |
| 4572 | {AttributeCommonInfo::AS_GNU, "may_alias" }, |
| 4573 | {AttributeCommonInfo::AS_CXX11, "gnu::may_alias" }, |
| 4574 | {AttributeCommonInfo::AS_C2x, "gnu::may_alias" }, |
| 4575 | }; |
| 4576 | struct ParsedAttrInfoMayAlias final : public ParsedAttrInfo { |
| 4577 | ParsedAttrInfoMayAlias() { |
| 4578 | AttrKind = ParsedAttr::AT_MayAlias; |
| 4579 | NumArgs = 0; |
| 4580 | OptArgs = 0; |
| 4581 | HasCustomParsing = 0; |
| 4582 | IsTargetSpecific = 0; |
| 4583 | IsType = 0; |
| 4584 | IsStmt = 0; |
| 4585 | IsKnownToGCC = 1; |
| 4586 | IsSupportedByPragmaAttribute = 0; |
| 4587 | Spellings = MayAliasSpellings; |
| 4588 | } |
| 4589 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 4590 | D->addAttr(::new (S.Context) MayAliasAttr(S.Context, Attr)); |
| 4591 | return AttributeApplied; |
| 4592 | } |
| 4593 | |
| 4594 | static const ParsedAttrInfoMayAlias Instance; |
| 4595 | }; |
| 4596 | const ParsedAttrInfoMayAlias ParsedAttrInfoMayAlias::Instance; |
| 4597 | static constexpr ParsedAttrInfo::Spelling MicroMipsSpellings[] = { |
| 4598 | {AttributeCommonInfo::AS_GNU, "micromips" }, |
| 4599 | {AttributeCommonInfo::AS_CXX11, "gnu::micromips" }, |
| 4600 | {AttributeCommonInfo::AS_C2x, "gnu::micromips" }, |
| 4601 | }; |
| 4602 | struct ParsedAttrInfoMicroMips final : public ParsedAttrInfo { |
| 4603 | ParsedAttrInfoMicroMips() { |
| 4604 | AttrKind = ParsedAttr::AT_MicroMips; |
| 4605 | NumArgs = 0; |
| 4606 | OptArgs = 0; |
| 4607 | HasCustomParsing = 0; |
| 4608 | IsTargetSpecific = 1; |
| 4609 | IsType = 0; |
| 4610 | IsStmt = 0; |
| 4611 | IsKnownToGCC = 1; |
| 4612 | IsSupportedByPragmaAttribute = 1; |
| 4613 | Spellings = MicroMipsSpellings; |
| 4614 | } |
| 4615 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4616 | if (!isa<FunctionDecl>(D)) { |
| 4617 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 4618 | << Attr << "functions" ; |
| 4619 | return false; |
| 4620 | } |
| 4621 | return true; |
| 4622 | } |
| 4623 | |
| 4624 | bool existsInTarget(const TargetInfo &Target) const override { |
| 4625 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 4626 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel); |
| 4627 | } |
| 4628 | |
| 4629 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4630 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 4631 | } |
| 4632 | |
| 4633 | static const ParsedAttrInfoMicroMips Instance; |
| 4634 | }; |
| 4635 | const ParsedAttrInfoMicroMips ParsedAttrInfoMicroMips::Instance; |
| 4636 | static constexpr ParsedAttrInfo::Spelling MinSizeSpellings[] = { |
| 4637 | {AttributeCommonInfo::AS_GNU, "minsize" }, |
| 4638 | {AttributeCommonInfo::AS_CXX11, "clang::minsize" }, |
| 4639 | {AttributeCommonInfo::AS_C2x, "clang::minsize" }, |
| 4640 | }; |
| 4641 | struct ParsedAttrInfoMinSize final : public ParsedAttrInfo { |
| 4642 | ParsedAttrInfoMinSize() { |
| 4643 | AttrKind = ParsedAttr::AT_MinSize; |
| 4644 | NumArgs = 0; |
| 4645 | OptArgs = 0; |
| 4646 | HasCustomParsing = 0; |
| 4647 | IsTargetSpecific = 0; |
| 4648 | IsType = 0; |
| 4649 | IsStmt = 0; |
| 4650 | IsKnownToGCC = 0; |
| 4651 | IsSupportedByPragmaAttribute = 1; |
| 4652 | Spellings = MinSizeSpellings; |
| 4653 | } |
| 4654 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4655 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 4656 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 4657 | << Attr << "functions and Objective-C methods" ; |
| 4658 | return false; |
| 4659 | } |
| 4660 | return true; |
| 4661 | } |
| 4662 | |
| 4663 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4664 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 4665 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 4666 | } |
| 4667 | |
| 4668 | static const ParsedAttrInfoMinSize Instance; |
| 4669 | }; |
| 4670 | const ParsedAttrInfoMinSize ParsedAttrInfoMinSize::Instance; |
| 4671 | static constexpr ParsedAttrInfo::Spelling MinVectorWidthSpellings[] = { |
| 4672 | {AttributeCommonInfo::AS_GNU, "min_vector_width" }, |
| 4673 | {AttributeCommonInfo::AS_CXX11, "clang::min_vector_width" }, |
| 4674 | {AttributeCommonInfo::AS_C2x, "clang::min_vector_width" }, |
| 4675 | }; |
| 4676 | struct ParsedAttrInfoMinVectorWidth final : public ParsedAttrInfo { |
| 4677 | ParsedAttrInfoMinVectorWidth() { |
| 4678 | AttrKind = ParsedAttr::AT_MinVectorWidth; |
| 4679 | NumArgs = 1; |
| 4680 | OptArgs = 0; |
| 4681 | HasCustomParsing = 0; |
| 4682 | IsTargetSpecific = 0; |
| 4683 | IsType = 0; |
| 4684 | IsStmt = 0; |
| 4685 | IsKnownToGCC = 0; |
| 4686 | IsSupportedByPragmaAttribute = 1; |
| 4687 | Spellings = MinVectorWidthSpellings; |
| 4688 | } |
| 4689 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4690 | if (!isa<FunctionDecl>(D)) { |
| 4691 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 4692 | << Attr << "functions" ; |
| 4693 | return false; |
| 4694 | } |
| 4695 | return true; |
| 4696 | } |
| 4697 | |
| 4698 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4699 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 4700 | } |
| 4701 | |
| 4702 | static const ParsedAttrInfoMinVectorWidth Instance; |
| 4703 | }; |
| 4704 | const ParsedAttrInfoMinVectorWidth ParsedAttrInfoMinVectorWidth::Instance; |
| 4705 | static constexpr ParsedAttrInfo::Spelling Mips16Spellings[] = { |
| 4706 | {AttributeCommonInfo::AS_GNU, "mips16" }, |
| 4707 | {AttributeCommonInfo::AS_CXX11, "gnu::mips16" }, |
| 4708 | {AttributeCommonInfo::AS_C2x, "gnu::mips16" }, |
| 4709 | }; |
| 4710 | struct ParsedAttrInfoMips16 final : public ParsedAttrInfo { |
| 4711 | ParsedAttrInfoMips16() { |
| 4712 | AttrKind = ParsedAttr::AT_Mips16; |
| 4713 | NumArgs = 0; |
| 4714 | OptArgs = 0; |
| 4715 | HasCustomParsing = 0; |
| 4716 | IsTargetSpecific = 1; |
| 4717 | IsType = 0; |
| 4718 | IsStmt = 0; |
| 4719 | IsKnownToGCC = 1; |
| 4720 | IsSupportedByPragmaAttribute = 1; |
| 4721 | Spellings = Mips16Spellings; |
| 4722 | } |
| 4723 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4724 | if (!isa<FunctionDecl>(D)) { |
| 4725 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 4726 | << Attr << "functions" ; |
| 4727 | return false; |
| 4728 | } |
| 4729 | return true; |
| 4730 | } |
| 4731 | |
| 4732 | bool existsInTarget(const TargetInfo &Target) const override { |
| 4733 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 4734 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel); |
| 4735 | } |
| 4736 | |
| 4737 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4738 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 4739 | } |
| 4740 | |
| 4741 | static const ParsedAttrInfoMips16 Instance; |
| 4742 | }; |
| 4743 | const ParsedAttrInfoMips16 ParsedAttrInfoMips16::Instance; |
| 4744 | static constexpr ParsedAttrInfo::Spelling MipsLongCallSpellings[] = { |
| 4745 | {AttributeCommonInfo::AS_GNU, "long_call" }, |
| 4746 | {AttributeCommonInfo::AS_CXX11, "gnu::long_call" }, |
| 4747 | {AttributeCommonInfo::AS_C2x, "gnu::long_call" }, |
| 4748 | {AttributeCommonInfo::AS_GNU, "far" }, |
| 4749 | {AttributeCommonInfo::AS_CXX11, "gnu::far" }, |
| 4750 | {AttributeCommonInfo::AS_C2x, "gnu::far" }, |
| 4751 | }; |
| 4752 | struct ParsedAttrInfoMipsLongCall final : public ParsedAttrInfo { |
| 4753 | ParsedAttrInfoMipsLongCall() { |
| 4754 | AttrKind = ParsedAttr::AT_MipsLongCall; |
| 4755 | NumArgs = 0; |
| 4756 | OptArgs = 0; |
| 4757 | HasCustomParsing = 0; |
| 4758 | IsTargetSpecific = 1; |
| 4759 | IsType = 0; |
| 4760 | IsStmt = 0; |
| 4761 | IsKnownToGCC = 1; |
| 4762 | IsSupportedByPragmaAttribute = 1; |
| 4763 | Spellings = MipsLongCallSpellings; |
| 4764 | } |
| 4765 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4766 | if (!isa<FunctionDecl>(D)) { |
| 4767 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4768 | << Attr << "functions" ; |
| 4769 | return false; |
| 4770 | } |
| 4771 | return true; |
| 4772 | } |
| 4773 | |
| 4774 | bool existsInTarget(const TargetInfo &Target) const override { |
| 4775 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 4776 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel || T.getArch() == llvm::Triple::mips64 || T.getArch() == llvm::Triple::mips64el); |
| 4777 | } |
| 4778 | |
| 4779 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 4780 | enum Spelling { |
| 4781 | GNU_long_call = 0, |
| 4782 | CXX11_gnu_long_call = 1, |
| 4783 | C2x_gnu_long_call = 2, |
| 4784 | GNU_far = 3, |
| 4785 | CXX11_gnu_far = 4, |
| 4786 | C2x_gnu_far = 5, |
| 4787 | SpellingNotCalculated = 15 |
| 4788 | |
| 4789 | }; |
| 4790 | |
| 4791 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 4792 | switch (Idx) { |
| 4793 | default: llvm_unreachable("Unknown spelling list index" ); |
| 4794 | case 0: return GNU_long_call; |
| 4795 | case 1: return CXX11_gnu_long_call; |
| 4796 | case 2: return C2x_gnu_long_call; |
| 4797 | case 3: return GNU_far; |
| 4798 | case 4: return CXX11_gnu_far; |
| 4799 | case 5: return C2x_gnu_far; |
| 4800 | } |
| 4801 | } |
| 4802 | |
| 4803 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4804 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 4805 | } |
| 4806 | |
| 4807 | static const ParsedAttrInfoMipsLongCall Instance; |
| 4808 | }; |
| 4809 | const ParsedAttrInfoMipsLongCall ParsedAttrInfoMipsLongCall::Instance; |
| 4810 | static constexpr ParsedAttrInfo::Spelling MipsShortCallSpellings[] = { |
| 4811 | {AttributeCommonInfo::AS_GNU, "short_call" }, |
| 4812 | {AttributeCommonInfo::AS_CXX11, "gnu::short_call" }, |
| 4813 | {AttributeCommonInfo::AS_C2x, "gnu::short_call" }, |
| 4814 | {AttributeCommonInfo::AS_GNU, "near" }, |
| 4815 | {AttributeCommonInfo::AS_CXX11, "gnu::near" }, |
| 4816 | {AttributeCommonInfo::AS_C2x, "gnu::near" }, |
| 4817 | }; |
| 4818 | struct ParsedAttrInfoMipsShortCall final : public ParsedAttrInfo { |
| 4819 | ParsedAttrInfoMipsShortCall() { |
| 4820 | AttrKind = ParsedAttr::AT_MipsShortCall; |
| 4821 | NumArgs = 0; |
| 4822 | OptArgs = 0; |
| 4823 | HasCustomParsing = 0; |
| 4824 | IsTargetSpecific = 1; |
| 4825 | IsType = 0; |
| 4826 | IsStmt = 0; |
| 4827 | IsKnownToGCC = 1; |
| 4828 | IsSupportedByPragmaAttribute = 1; |
| 4829 | Spellings = MipsShortCallSpellings; |
| 4830 | } |
| 4831 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4832 | if (!isa<FunctionDecl>(D)) { |
| 4833 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4834 | << Attr << "functions" ; |
| 4835 | return false; |
| 4836 | } |
| 4837 | return true; |
| 4838 | } |
| 4839 | |
| 4840 | bool existsInTarget(const TargetInfo &Target) const override { |
| 4841 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 4842 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel || T.getArch() == llvm::Triple::mips64 || T.getArch() == llvm::Triple::mips64el); |
| 4843 | } |
| 4844 | |
| 4845 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 4846 | enum Spelling { |
| 4847 | GNU_short_call = 0, |
| 4848 | CXX11_gnu_short_call = 1, |
| 4849 | C2x_gnu_short_call = 2, |
| 4850 | GNU_near = 3, |
| 4851 | CXX11_gnu_near = 4, |
| 4852 | C2x_gnu_near = 5, |
| 4853 | SpellingNotCalculated = 15 |
| 4854 | |
| 4855 | }; |
| 4856 | |
| 4857 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 4858 | switch (Idx) { |
| 4859 | default: llvm_unreachable("Unknown spelling list index" ); |
| 4860 | case 0: return GNU_short_call; |
| 4861 | case 1: return CXX11_gnu_short_call; |
| 4862 | case 2: return C2x_gnu_short_call; |
| 4863 | case 3: return GNU_near; |
| 4864 | case 4: return CXX11_gnu_near; |
| 4865 | case 5: return C2x_gnu_near; |
| 4866 | } |
| 4867 | } |
| 4868 | |
| 4869 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4870 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 4871 | } |
| 4872 | |
| 4873 | static const ParsedAttrInfoMipsShortCall Instance; |
| 4874 | }; |
| 4875 | const ParsedAttrInfoMipsShortCall ParsedAttrInfoMipsShortCall::Instance; |
| 4876 | static constexpr ParsedAttrInfo::Spelling ModeSpellings[] = { |
| 4877 | {AttributeCommonInfo::AS_GNU, "mode" }, |
| 4878 | {AttributeCommonInfo::AS_CXX11, "gnu::mode" }, |
| 4879 | {AttributeCommonInfo::AS_C2x, "gnu::mode" }, |
| 4880 | }; |
| 4881 | struct ParsedAttrInfoMode final : public ParsedAttrInfo { |
| 4882 | ParsedAttrInfoMode() { |
| 4883 | AttrKind = ParsedAttr::AT_Mode; |
| 4884 | NumArgs = 1; |
| 4885 | OptArgs = 0; |
| 4886 | HasCustomParsing = 0; |
| 4887 | IsTargetSpecific = 0; |
| 4888 | IsType = 0; |
| 4889 | IsStmt = 0; |
| 4890 | IsKnownToGCC = 1; |
| 4891 | IsSupportedByPragmaAttribute = 0; |
| 4892 | Spellings = ModeSpellings; |
| 4893 | } |
| 4894 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4895 | if (!isa<VarDecl>(D) && !isa<EnumDecl>(D) && !isa<TypedefNameDecl>(D) && !isa<FieldDecl>(D)) { |
| 4896 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 4897 | << Attr << "variables, enums, typedefs, and non-static data members" ; |
| 4898 | return false; |
| 4899 | } |
| 4900 | return true; |
| 4901 | } |
| 4902 | |
| 4903 | static const ParsedAttrInfoMode Instance; |
| 4904 | }; |
| 4905 | const ParsedAttrInfoMode ParsedAttrInfoMode::Instance; |
| 4906 | static constexpr ParsedAttrInfo::Spelling NSConsumedSpellings[] = { |
| 4907 | {AttributeCommonInfo::AS_GNU, "ns_consumed" }, |
| 4908 | {AttributeCommonInfo::AS_CXX11, "clang::ns_consumed" }, |
| 4909 | {AttributeCommonInfo::AS_C2x, "clang::ns_consumed" }, |
| 4910 | }; |
| 4911 | struct ParsedAttrInfoNSConsumed final : public ParsedAttrInfo { |
| 4912 | ParsedAttrInfoNSConsumed() { |
| 4913 | AttrKind = ParsedAttr::AT_NSConsumed; |
| 4914 | NumArgs = 0; |
| 4915 | OptArgs = 0; |
| 4916 | HasCustomParsing = 0; |
| 4917 | IsTargetSpecific = 0; |
| 4918 | IsType = 0; |
| 4919 | IsStmt = 0; |
| 4920 | IsKnownToGCC = 0; |
| 4921 | IsSupportedByPragmaAttribute = 1; |
| 4922 | Spellings = NSConsumedSpellings; |
| 4923 | } |
| 4924 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4925 | if (!isa<ParmVarDecl>(D)) { |
| 4926 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4927 | << Attr << "parameters" ; |
| 4928 | return false; |
| 4929 | } |
| 4930 | return true; |
| 4931 | } |
| 4932 | |
| 4933 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4934 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 4935 | } |
| 4936 | |
| 4937 | static const ParsedAttrInfoNSConsumed Instance; |
| 4938 | }; |
| 4939 | const ParsedAttrInfoNSConsumed ParsedAttrInfoNSConsumed::Instance; |
| 4940 | static constexpr ParsedAttrInfo::Spelling NSConsumesSelfSpellings[] = { |
| 4941 | {AttributeCommonInfo::AS_GNU, "ns_consumes_self" }, |
| 4942 | {AttributeCommonInfo::AS_CXX11, "clang::ns_consumes_self" }, |
| 4943 | {AttributeCommonInfo::AS_C2x, "clang::ns_consumes_self" }, |
| 4944 | }; |
| 4945 | struct ParsedAttrInfoNSConsumesSelf final : public ParsedAttrInfo { |
| 4946 | ParsedAttrInfoNSConsumesSelf() { |
| 4947 | AttrKind = ParsedAttr::AT_NSConsumesSelf; |
| 4948 | NumArgs = 0; |
| 4949 | OptArgs = 0; |
| 4950 | HasCustomParsing = 0; |
| 4951 | IsTargetSpecific = 0; |
| 4952 | IsType = 0; |
| 4953 | IsStmt = 0; |
| 4954 | IsKnownToGCC = 0; |
| 4955 | IsSupportedByPragmaAttribute = 1; |
| 4956 | Spellings = NSConsumesSelfSpellings; |
| 4957 | } |
| 4958 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4959 | if (!isa<ObjCMethodDecl>(D)) { |
| 4960 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 4961 | << Attr << "Objective-C methods" ; |
| 4962 | return false; |
| 4963 | } |
| 4964 | return true; |
| 4965 | } |
| 4966 | |
| 4967 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 4968 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 4969 | } |
| 4970 | |
| 4971 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 4972 | D->addAttr(::new (S.Context) NSConsumesSelfAttr(S.Context, Attr)); |
| 4973 | return AttributeApplied; |
| 4974 | } |
| 4975 | |
| 4976 | static const ParsedAttrInfoNSConsumesSelf Instance; |
| 4977 | }; |
| 4978 | const ParsedAttrInfoNSConsumesSelf ParsedAttrInfoNSConsumesSelf::Instance; |
| 4979 | static constexpr ParsedAttrInfo::Spelling NSErrorDomainSpellings[] = { |
| 4980 | {AttributeCommonInfo::AS_GNU, "ns_error_domain" }, |
| 4981 | }; |
| 4982 | struct ParsedAttrInfoNSErrorDomain final : public ParsedAttrInfo { |
| 4983 | ParsedAttrInfoNSErrorDomain() { |
| 4984 | AttrKind = ParsedAttr::AT_NSErrorDomain; |
| 4985 | NumArgs = 1; |
| 4986 | OptArgs = 0; |
| 4987 | HasCustomParsing = 0; |
| 4988 | IsTargetSpecific = 0; |
| 4989 | IsType = 0; |
| 4990 | IsStmt = 0; |
| 4991 | IsKnownToGCC = 0; |
| 4992 | IsSupportedByPragmaAttribute = 1; |
| 4993 | Spellings = NSErrorDomainSpellings; |
| 4994 | } |
| 4995 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 4996 | if (!isa<EnumDecl>(D)) { |
| 4997 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 4998 | << Attr << "enums" ; |
| 4999 | return false; |
| 5000 | } |
| 5001 | return true; |
| 5002 | } |
| 5003 | |
| 5004 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5005 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
| 5006 | } |
| 5007 | |
| 5008 | static const ParsedAttrInfoNSErrorDomain Instance; |
| 5009 | }; |
| 5010 | const ParsedAttrInfoNSErrorDomain ParsedAttrInfoNSErrorDomain::Instance; |
| 5011 | static constexpr ParsedAttrInfo::Spelling NSReturnsAutoreleasedSpellings[] = { |
| 5012 | {AttributeCommonInfo::AS_GNU, "ns_returns_autoreleased" }, |
| 5013 | {AttributeCommonInfo::AS_CXX11, "clang::ns_returns_autoreleased" }, |
| 5014 | {AttributeCommonInfo::AS_C2x, "clang::ns_returns_autoreleased" }, |
| 5015 | }; |
| 5016 | struct ParsedAttrInfoNSReturnsAutoreleased final : public ParsedAttrInfo { |
| 5017 | ParsedAttrInfoNSReturnsAutoreleased() { |
| 5018 | AttrKind = ParsedAttr::AT_NSReturnsAutoreleased; |
| 5019 | NumArgs = 0; |
| 5020 | OptArgs = 0; |
| 5021 | HasCustomParsing = 0; |
| 5022 | IsTargetSpecific = 0; |
| 5023 | IsType = 0; |
| 5024 | IsStmt = 0; |
| 5025 | IsKnownToGCC = 0; |
| 5026 | IsSupportedByPragmaAttribute = 0; |
| 5027 | Spellings = NSReturnsAutoreleasedSpellings; |
| 5028 | } |
| 5029 | static const ParsedAttrInfoNSReturnsAutoreleased Instance; |
| 5030 | }; |
| 5031 | const ParsedAttrInfoNSReturnsAutoreleased ParsedAttrInfoNSReturnsAutoreleased::Instance; |
| 5032 | static constexpr ParsedAttrInfo::Spelling NSReturnsNotRetainedSpellings[] = { |
| 5033 | {AttributeCommonInfo::AS_GNU, "ns_returns_not_retained" }, |
| 5034 | {AttributeCommonInfo::AS_CXX11, "clang::ns_returns_not_retained" }, |
| 5035 | {AttributeCommonInfo::AS_C2x, "clang::ns_returns_not_retained" }, |
| 5036 | }; |
| 5037 | struct ParsedAttrInfoNSReturnsNotRetained final : public ParsedAttrInfo { |
| 5038 | ParsedAttrInfoNSReturnsNotRetained() { |
| 5039 | AttrKind = ParsedAttr::AT_NSReturnsNotRetained; |
| 5040 | NumArgs = 0; |
| 5041 | OptArgs = 0; |
| 5042 | HasCustomParsing = 0; |
| 5043 | IsTargetSpecific = 0; |
| 5044 | IsType = 0; |
| 5045 | IsStmt = 0; |
| 5046 | IsKnownToGCC = 0; |
| 5047 | IsSupportedByPragmaAttribute = 0; |
| 5048 | Spellings = NSReturnsNotRetainedSpellings; |
| 5049 | } |
| 5050 | static const ParsedAttrInfoNSReturnsNotRetained Instance; |
| 5051 | }; |
| 5052 | const ParsedAttrInfoNSReturnsNotRetained ParsedAttrInfoNSReturnsNotRetained::Instance; |
| 5053 | static constexpr ParsedAttrInfo::Spelling NSReturnsRetainedSpellings[] = { |
| 5054 | {AttributeCommonInfo::AS_GNU, "ns_returns_retained" }, |
| 5055 | {AttributeCommonInfo::AS_CXX11, "clang::ns_returns_retained" }, |
| 5056 | {AttributeCommonInfo::AS_C2x, "clang::ns_returns_retained" }, |
| 5057 | }; |
| 5058 | struct ParsedAttrInfoNSReturnsRetained final : public ParsedAttrInfo { |
| 5059 | ParsedAttrInfoNSReturnsRetained() { |
| 5060 | AttrKind = ParsedAttr::AT_NSReturnsRetained; |
| 5061 | NumArgs = 0; |
| 5062 | OptArgs = 0; |
| 5063 | HasCustomParsing = 0; |
| 5064 | IsTargetSpecific = 0; |
| 5065 | IsType = 1; |
| 5066 | IsStmt = 0; |
| 5067 | IsKnownToGCC = 0; |
| 5068 | IsSupportedByPragmaAttribute = 0; |
| 5069 | Spellings = NSReturnsRetainedSpellings; |
| 5070 | } |
| 5071 | static const ParsedAttrInfoNSReturnsRetained Instance; |
| 5072 | }; |
| 5073 | const ParsedAttrInfoNSReturnsRetained ParsedAttrInfoNSReturnsRetained::Instance; |
| 5074 | static constexpr ParsedAttrInfo::Spelling NakedSpellings[] = { |
| 5075 | {AttributeCommonInfo::AS_GNU, "naked" }, |
| 5076 | {AttributeCommonInfo::AS_CXX11, "gnu::naked" }, |
| 5077 | {AttributeCommonInfo::AS_C2x, "gnu::naked" }, |
| 5078 | {AttributeCommonInfo::AS_Declspec, "naked" }, |
| 5079 | }; |
| 5080 | struct ParsedAttrInfoNaked final : public ParsedAttrInfo { |
| 5081 | ParsedAttrInfoNaked() { |
| 5082 | AttrKind = ParsedAttr::AT_Naked; |
| 5083 | NumArgs = 0; |
| 5084 | OptArgs = 0; |
| 5085 | HasCustomParsing = 0; |
| 5086 | IsTargetSpecific = 0; |
| 5087 | IsType = 0; |
| 5088 | IsStmt = 0; |
| 5089 | IsKnownToGCC = 1; |
| 5090 | IsSupportedByPragmaAttribute = 1; |
| 5091 | Spellings = NakedSpellings; |
| 5092 | } |
| 5093 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5094 | if (!isa<FunctionDecl>(D)) { |
| 5095 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5096 | << Attr << "functions" ; |
| 5097 | return false; |
| 5098 | } |
| 5099 | return true; |
| 5100 | } |
| 5101 | |
| 5102 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5103 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5104 | } |
| 5105 | |
| 5106 | static const ParsedAttrInfoNaked Instance; |
| 5107 | }; |
| 5108 | const ParsedAttrInfoNaked ParsedAttrInfoNaked::Instance; |
| 5109 | static constexpr ParsedAttrInfo::Spelling NeonPolyVectorTypeSpellings[] = { |
| 5110 | {AttributeCommonInfo::AS_GNU, "neon_polyvector_type" }, |
| 5111 | {AttributeCommonInfo::AS_CXX11, "clang::neon_polyvector_type" }, |
| 5112 | {AttributeCommonInfo::AS_C2x, "clang::neon_polyvector_type" }, |
| 5113 | }; |
| 5114 | struct ParsedAttrInfoNeonPolyVectorType final : public ParsedAttrInfo { |
| 5115 | ParsedAttrInfoNeonPolyVectorType() { |
| 5116 | AttrKind = ParsedAttr::AT_NeonPolyVectorType; |
| 5117 | NumArgs = 1; |
| 5118 | OptArgs = 0; |
| 5119 | HasCustomParsing = 0; |
| 5120 | IsTargetSpecific = 0; |
| 5121 | IsType = 1; |
| 5122 | IsStmt = 0; |
| 5123 | IsKnownToGCC = 0; |
| 5124 | IsSupportedByPragmaAttribute = 0; |
| 5125 | Spellings = NeonPolyVectorTypeSpellings; |
| 5126 | } |
| 5127 | static const ParsedAttrInfoNeonPolyVectorType Instance; |
| 5128 | }; |
| 5129 | const ParsedAttrInfoNeonPolyVectorType ParsedAttrInfoNeonPolyVectorType::Instance; |
| 5130 | static constexpr ParsedAttrInfo::Spelling NeonVectorTypeSpellings[] = { |
| 5131 | {AttributeCommonInfo::AS_GNU, "neon_vector_type" }, |
| 5132 | {AttributeCommonInfo::AS_CXX11, "clang::neon_vector_type" }, |
| 5133 | {AttributeCommonInfo::AS_C2x, "clang::neon_vector_type" }, |
| 5134 | }; |
| 5135 | struct ParsedAttrInfoNeonVectorType final : public ParsedAttrInfo { |
| 5136 | ParsedAttrInfoNeonVectorType() { |
| 5137 | AttrKind = ParsedAttr::AT_NeonVectorType; |
| 5138 | NumArgs = 1; |
| 5139 | OptArgs = 0; |
| 5140 | HasCustomParsing = 0; |
| 5141 | IsTargetSpecific = 0; |
| 5142 | IsType = 1; |
| 5143 | IsStmt = 0; |
| 5144 | IsKnownToGCC = 0; |
| 5145 | IsSupportedByPragmaAttribute = 0; |
| 5146 | Spellings = NeonVectorTypeSpellings; |
| 5147 | } |
| 5148 | static const ParsedAttrInfoNeonVectorType Instance; |
| 5149 | }; |
| 5150 | const ParsedAttrInfoNeonVectorType ParsedAttrInfoNeonVectorType::Instance; |
| 5151 | static constexpr ParsedAttrInfo::Spelling NoAliasSpellings[] = { |
| 5152 | {AttributeCommonInfo::AS_Declspec, "noalias" }, |
| 5153 | }; |
| 5154 | struct ParsedAttrInfoNoAlias final : public ParsedAttrInfo { |
| 5155 | ParsedAttrInfoNoAlias() { |
| 5156 | AttrKind = ParsedAttr::AT_NoAlias; |
| 5157 | NumArgs = 0; |
| 5158 | OptArgs = 0; |
| 5159 | HasCustomParsing = 0; |
| 5160 | IsTargetSpecific = 0; |
| 5161 | IsType = 0; |
| 5162 | IsStmt = 0; |
| 5163 | IsKnownToGCC = 0; |
| 5164 | IsSupportedByPragmaAttribute = 0; |
| 5165 | Spellings = NoAliasSpellings; |
| 5166 | } |
| 5167 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5168 | if (!isa<FunctionDecl>(D)) { |
| 5169 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5170 | << Attr << "functions" ; |
| 5171 | return false; |
| 5172 | } |
| 5173 | return true; |
| 5174 | } |
| 5175 | |
| 5176 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5177 | D->addAttr(::new (S.Context) NoAliasAttr(S.Context, Attr)); |
| 5178 | return AttributeApplied; |
| 5179 | } |
| 5180 | |
| 5181 | static const ParsedAttrInfoNoAlias Instance; |
| 5182 | }; |
| 5183 | const ParsedAttrInfoNoAlias ParsedAttrInfoNoAlias::Instance; |
| 5184 | static constexpr ParsedAttrInfo::Spelling NoBuiltinSpellings[] = { |
| 5185 | {AttributeCommonInfo::AS_GNU, "no_builtin" }, |
| 5186 | {AttributeCommonInfo::AS_CXX11, "clang::no_builtin" }, |
| 5187 | {AttributeCommonInfo::AS_C2x, "clang::no_builtin" }, |
| 5188 | }; |
| 5189 | struct ParsedAttrInfoNoBuiltin final : public ParsedAttrInfo { |
| 5190 | ParsedAttrInfoNoBuiltin() { |
| 5191 | AttrKind = ParsedAttr::AT_NoBuiltin; |
| 5192 | NumArgs = 0; |
| 5193 | OptArgs = 15; |
| 5194 | HasCustomParsing = 0; |
| 5195 | IsTargetSpecific = 0; |
| 5196 | IsType = 0; |
| 5197 | IsStmt = 0; |
| 5198 | IsKnownToGCC = 0; |
| 5199 | IsSupportedByPragmaAttribute = 1; |
| 5200 | Spellings = NoBuiltinSpellings; |
| 5201 | } |
| 5202 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5203 | if (!isa<FunctionDecl>(D)) { |
| 5204 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5205 | << Attr << "functions" ; |
| 5206 | return false; |
| 5207 | } |
| 5208 | return true; |
| 5209 | } |
| 5210 | |
| 5211 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5212 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5213 | } |
| 5214 | |
| 5215 | static const ParsedAttrInfoNoBuiltin Instance; |
| 5216 | }; |
| 5217 | const ParsedAttrInfoNoBuiltin ParsedAttrInfoNoBuiltin::Instance; |
| 5218 | static constexpr ParsedAttrInfo::Spelling NoCommonSpellings[] = { |
| 5219 | {AttributeCommonInfo::AS_GNU, "nocommon" }, |
| 5220 | {AttributeCommonInfo::AS_CXX11, "gnu::nocommon" }, |
| 5221 | {AttributeCommonInfo::AS_C2x, "gnu::nocommon" }, |
| 5222 | }; |
| 5223 | struct ParsedAttrInfoNoCommon final : public ParsedAttrInfo { |
| 5224 | ParsedAttrInfoNoCommon() { |
| 5225 | AttrKind = ParsedAttr::AT_NoCommon; |
| 5226 | NumArgs = 0; |
| 5227 | OptArgs = 0; |
| 5228 | HasCustomParsing = 0; |
| 5229 | IsTargetSpecific = 0; |
| 5230 | IsType = 0; |
| 5231 | IsStmt = 0; |
| 5232 | IsKnownToGCC = 1; |
| 5233 | IsSupportedByPragmaAttribute = 1; |
| 5234 | Spellings = NoCommonSpellings; |
| 5235 | } |
| 5236 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5237 | if (!isa<VarDecl>(D)) { |
| 5238 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5239 | << Attr << "variables" ; |
| 5240 | return false; |
| 5241 | } |
| 5242 | return true; |
| 5243 | } |
| 5244 | |
| 5245 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5246 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 5247 | } |
| 5248 | |
| 5249 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5250 | D->addAttr(::new (S.Context) NoCommonAttr(S.Context, Attr)); |
| 5251 | return AttributeApplied; |
| 5252 | } |
| 5253 | |
| 5254 | static const ParsedAttrInfoNoCommon Instance; |
| 5255 | }; |
| 5256 | const ParsedAttrInfoNoCommon ParsedAttrInfoNoCommon::Instance; |
| 5257 | static constexpr ParsedAttrInfo::Spelling NoDebugSpellings[] = { |
| 5258 | {AttributeCommonInfo::AS_GNU, "nodebug" }, |
| 5259 | {AttributeCommonInfo::AS_CXX11, "gnu::nodebug" }, |
| 5260 | {AttributeCommonInfo::AS_C2x, "gnu::nodebug" }, |
| 5261 | }; |
| 5262 | struct ParsedAttrInfoNoDebug final : public ParsedAttrInfo { |
| 5263 | ParsedAttrInfoNoDebug() { |
| 5264 | AttrKind = ParsedAttr::AT_NoDebug; |
| 5265 | NumArgs = 0; |
| 5266 | OptArgs = 0; |
| 5267 | HasCustomParsing = 0; |
| 5268 | IsTargetSpecific = 0; |
| 5269 | IsType = 0; |
| 5270 | IsStmt = 0; |
| 5271 | IsKnownToGCC = 1; |
| 5272 | IsSupportedByPragmaAttribute = 1; |
| 5273 | Spellings = NoDebugSpellings; |
| 5274 | } |
| 5275 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5276 | if (!isa<TypedefNameDecl>(D) && !isFunctionLike(D) && !isa<ObjCMethodDecl>(D) && !isNonParmVar(D)) { |
| 5277 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5278 | << Attr << "typedefs, functions, function pointers, Objective-C methods, and variables" ; |
| 5279 | return false; |
| 5280 | } |
| 5281 | return true; |
| 5282 | } |
| 5283 | |
| 5284 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5285 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
| 5286 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
| 5287 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 5288 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_not_is_parameter, /*IsSupported=*/true)); |
| 5289 | } |
| 5290 | |
| 5291 | static const ParsedAttrInfoNoDebug Instance; |
| 5292 | }; |
| 5293 | const ParsedAttrInfoNoDebug ParsedAttrInfoNoDebug::Instance; |
| 5294 | static constexpr ParsedAttrInfo::Spelling NoDerefSpellings[] = { |
| 5295 | {AttributeCommonInfo::AS_GNU, "noderef" }, |
| 5296 | {AttributeCommonInfo::AS_CXX11, "clang::noderef" }, |
| 5297 | {AttributeCommonInfo::AS_C2x, "clang::noderef" }, |
| 5298 | }; |
| 5299 | struct ParsedAttrInfoNoDeref final : public ParsedAttrInfo { |
| 5300 | ParsedAttrInfoNoDeref() { |
| 5301 | AttrKind = ParsedAttr::AT_NoDeref; |
| 5302 | NumArgs = 0; |
| 5303 | OptArgs = 0; |
| 5304 | HasCustomParsing = 0; |
| 5305 | IsTargetSpecific = 0; |
| 5306 | IsType = 1; |
| 5307 | IsStmt = 0; |
| 5308 | IsKnownToGCC = 0; |
| 5309 | IsSupportedByPragmaAttribute = 0; |
| 5310 | Spellings = NoDerefSpellings; |
| 5311 | } |
| 5312 | static const ParsedAttrInfoNoDeref Instance; |
| 5313 | }; |
| 5314 | const ParsedAttrInfoNoDeref ParsedAttrInfoNoDeref::Instance; |
| 5315 | static constexpr ParsedAttrInfo::Spelling NoDestroySpellings[] = { |
| 5316 | {AttributeCommonInfo::AS_GNU, "no_destroy" }, |
| 5317 | {AttributeCommonInfo::AS_CXX11, "clang::no_destroy" }, |
| 5318 | }; |
| 5319 | struct ParsedAttrInfoNoDestroy final : public ParsedAttrInfo { |
| 5320 | ParsedAttrInfoNoDestroy() { |
| 5321 | AttrKind = ParsedAttr::AT_NoDestroy; |
| 5322 | NumArgs = 0; |
| 5323 | OptArgs = 0; |
| 5324 | HasCustomParsing = 0; |
| 5325 | IsTargetSpecific = 0; |
| 5326 | IsType = 0; |
| 5327 | IsStmt = 0; |
| 5328 | IsKnownToGCC = 0; |
| 5329 | IsSupportedByPragmaAttribute = 1; |
| 5330 | Spellings = NoDestroySpellings; |
| 5331 | } |
| 5332 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5333 | if (!isa<VarDecl>(D)) { |
| 5334 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5335 | << Attr << "variables" ; |
| 5336 | return false; |
| 5337 | } |
| 5338 | return true; |
| 5339 | } |
| 5340 | |
| 5341 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5342 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 5343 | } |
| 5344 | |
| 5345 | static const ParsedAttrInfoNoDestroy Instance; |
| 5346 | }; |
| 5347 | const ParsedAttrInfoNoDestroy ParsedAttrInfoNoDestroy::Instance; |
| 5348 | static constexpr ParsedAttrInfo::Spelling NoDuplicateSpellings[] = { |
| 5349 | {AttributeCommonInfo::AS_GNU, "noduplicate" }, |
| 5350 | {AttributeCommonInfo::AS_CXX11, "clang::noduplicate" }, |
| 5351 | {AttributeCommonInfo::AS_C2x, "clang::noduplicate" }, |
| 5352 | }; |
| 5353 | struct ParsedAttrInfoNoDuplicate final : public ParsedAttrInfo { |
| 5354 | ParsedAttrInfoNoDuplicate() { |
| 5355 | AttrKind = ParsedAttr::AT_NoDuplicate; |
| 5356 | NumArgs = 0; |
| 5357 | OptArgs = 0; |
| 5358 | HasCustomParsing = 0; |
| 5359 | IsTargetSpecific = 0; |
| 5360 | IsType = 0; |
| 5361 | IsStmt = 0; |
| 5362 | IsKnownToGCC = 0; |
| 5363 | IsSupportedByPragmaAttribute = 1; |
| 5364 | Spellings = NoDuplicateSpellings; |
| 5365 | } |
| 5366 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5367 | if (!isa<FunctionDecl>(D)) { |
| 5368 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5369 | << Attr << "functions" ; |
| 5370 | return false; |
| 5371 | } |
| 5372 | return true; |
| 5373 | } |
| 5374 | |
| 5375 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5376 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5377 | } |
| 5378 | |
| 5379 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5380 | D->addAttr(::new (S.Context) NoDuplicateAttr(S.Context, Attr)); |
| 5381 | return AttributeApplied; |
| 5382 | } |
| 5383 | |
| 5384 | static const ParsedAttrInfoNoDuplicate Instance; |
| 5385 | }; |
| 5386 | const ParsedAttrInfoNoDuplicate ParsedAttrInfoNoDuplicate::Instance; |
| 5387 | static constexpr ParsedAttrInfo::Spelling NoEscapeSpellings[] = { |
| 5388 | {AttributeCommonInfo::AS_GNU, "noescape" }, |
| 5389 | {AttributeCommonInfo::AS_CXX11, "clang::noescape" }, |
| 5390 | {AttributeCommonInfo::AS_C2x, "clang::noescape" }, |
| 5391 | }; |
| 5392 | struct ParsedAttrInfoNoEscape final : public ParsedAttrInfo { |
| 5393 | ParsedAttrInfoNoEscape() { |
| 5394 | AttrKind = ParsedAttr::AT_NoEscape; |
| 5395 | NumArgs = 0; |
| 5396 | OptArgs = 0; |
| 5397 | HasCustomParsing = 0; |
| 5398 | IsTargetSpecific = 0; |
| 5399 | IsType = 0; |
| 5400 | IsStmt = 0; |
| 5401 | IsKnownToGCC = 0; |
| 5402 | IsSupportedByPragmaAttribute = 1; |
| 5403 | Spellings = NoEscapeSpellings; |
| 5404 | } |
| 5405 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5406 | if (!isa<ParmVarDecl>(D)) { |
| 5407 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5408 | << Attr << "parameters" ; |
| 5409 | return false; |
| 5410 | } |
| 5411 | return true; |
| 5412 | } |
| 5413 | |
| 5414 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5415 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 5416 | } |
| 5417 | |
| 5418 | static const ParsedAttrInfoNoEscape Instance; |
| 5419 | }; |
| 5420 | const ParsedAttrInfoNoEscape ParsedAttrInfoNoEscape::Instance; |
| 5421 | static constexpr ParsedAttrInfo::Spelling NoInlineSpellings[] = { |
| 5422 | {AttributeCommonInfo::AS_GNU, "noinline" }, |
| 5423 | {AttributeCommonInfo::AS_CXX11, "gnu::noinline" }, |
| 5424 | {AttributeCommonInfo::AS_C2x, "gnu::noinline" }, |
| 5425 | {AttributeCommonInfo::AS_Declspec, "noinline" }, |
| 5426 | }; |
| 5427 | struct ParsedAttrInfoNoInline final : public ParsedAttrInfo { |
| 5428 | ParsedAttrInfoNoInline() { |
| 5429 | AttrKind = ParsedAttr::AT_NoInline; |
| 5430 | NumArgs = 0; |
| 5431 | OptArgs = 0; |
| 5432 | HasCustomParsing = 0; |
| 5433 | IsTargetSpecific = 0; |
| 5434 | IsType = 0; |
| 5435 | IsStmt = 0; |
| 5436 | IsKnownToGCC = 1; |
| 5437 | IsSupportedByPragmaAttribute = 1; |
| 5438 | Spellings = NoInlineSpellings; |
| 5439 | } |
| 5440 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5441 | if (!isa<FunctionDecl>(D)) { |
| 5442 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5443 | << Attr << "functions" ; |
| 5444 | return false; |
| 5445 | } |
| 5446 | return true; |
| 5447 | } |
| 5448 | |
| 5449 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5450 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5451 | } |
| 5452 | |
| 5453 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5454 | D->addAttr(::new (S.Context) NoInlineAttr(S.Context, Attr)); |
| 5455 | return AttributeApplied; |
| 5456 | } |
| 5457 | |
| 5458 | static const ParsedAttrInfoNoInline Instance; |
| 5459 | }; |
| 5460 | const ParsedAttrInfoNoInline ParsedAttrInfoNoInline::Instance; |
| 5461 | static constexpr ParsedAttrInfo::Spelling NoInstrumentFunctionSpellings[] = { |
| 5462 | {AttributeCommonInfo::AS_GNU, "no_instrument_function" }, |
| 5463 | {AttributeCommonInfo::AS_CXX11, "gnu::no_instrument_function" }, |
| 5464 | {AttributeCommonInfo::AS_C2x, "gnu::no_instrument_function" }, |
| 5465 | }; |
| 5466 | struct ParsedAttrInfoNoInstrumentFunction final : public ParsedAttrInfo { |
| 5467 | ParsedAttrInfoNoInstrumentFunction() { |
| 5468 | AttrKind = ParsedAttr::AT_NoInstrumentFunction; |
| 5469 | NumArgs = 0; |
| 5470 | OptArgs = 0; |
| 5471 | HasCustomParsing = 0; |
| 5472 | IsTargetSpecific = 0; |
| 5473 | IsType = 0; |
| 5474 | IsStmt = 0; |
| 5475 | IsKnownToGCC = 1; |
| 5476 | IsSupportedByPragmaAttribute = 1; |
| 5477 | Spellings = NoInstrumentFunctionSpellings; |
| 5478 | } |
| 5479 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5480 | if (!isa<FunctionDecl>(D)) { |
| 5481 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5482 | << Attr << "functions" ; |
| 5483 | return false; |
| 5484 | } |
| 5485 | return true; |
| 5486 | } |
| 5487 | |
| 5488 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5489 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5490 | } |
| 5491 | |
| 5492 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5493 | D->addAttr(::new (S.Context) NoInstrumentFunctionAttr(S.Context, Attr)); |
| 5494 | return AttributeApplied; |
| 5495 | } |
| 5496 | |
| 5497 | static const ParsedAttrInfoNoInstrumentFunction Instance; |
| 5498 | }; |
| 5499 | const ParsedAttrInfoNoInstrumentFunction ParsedAttrInfoNoInstrumentFunction::Instance; |
| 5500 | static constexpr ParsedAttrInfo::Spelling NoMergeSpellings[] = { |
| 5501 | {AttributeCommonInfo::AS_GNU, "nomerge" }, |
| 5502 | {AttributeCommonInfo::AS_CXX11, "clang::nomerge" }, |
| 5503 | {AttributeCommonInfo::AS_C2x, "clang::nomerge" }, |
| 5504 | }; |
| 5505 | struct ParsedAttrInfoNoMerge final : public ParsedAttrInfo { |
| 5506 | ParsedAttrInfoNoMerge() { |
| 5507 | AttrKind = ParsedAttr::AT_NoMerge; |
| 5508 | NumArgs = 0; |
| 5509 | OptArgs = 0; |
| 5510 | HasCustomParsing = 0; |
| 5511 | IsTargetSpecific = 0; |
| 5512 | IsType = 0; |
| 5513 | IsStmt = 1; |
| 5514 | IsKnownToGCC = 0; |
| 5515 | IsSupportedByPragmaAttribute = 1; |
| 5516 | Spellings = NoMergeSpellings; |
| 5517 | } |
| 5518 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5519 | if (!isa<FunctionDecl>(D)) { |
| 5520 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 5521 | << Attr << "functions and statements" ; |
| 5522 | return false; |
| 5523 | } |
| 5524 | return true; |
| 5525 | } |
| 5526 | |
| 5527 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5528 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5529 | } |
| 5530 | |
| 5531 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5532 | D->addAttr(::new (S.Context) NoMergeAttr(S.Context, Attr)); |
| 5533 | return AttributeApplied; |
| 5534 | } |
| 5535 | |
| 5536 | static const ParsedAttrInfoNoMerge Instance; |
| 5537 | }; |
| 5538 | const ParsedAttrInfoNoMerge ParsedAttrInfoNoMerge::Instance; |
| 5539 | static constexpr ParsedAttrInfo::Spelling NoMicroMipsSpellings[] = { |
| 5540 | {AttributeCommonInfo::AS_GNU, "nomicromips" }, |
| 5541 | {AttributeCommonInfo::AS_CXX11, "gnu::nomicromips" }, |
| 5542 | {AttributeCommonInfo::AS_C2x, "gnu::nomicromips" }, |
| 5543 | }; |
| 5544 | struct ParsedAttrInfoNoMicroMips final : public ParsedAttrInfo { |
| 5545 | ParsedAttrInfoNoMicroMips() { |
| 5546 | AttrKind = ParsedAttr::AT_NoMicroMips; |
| 5547 | NumArgs = 0; |
| 5548 | OptArgs = 0; |
| 5549 | HasCustomParsing = 0; |
| 5550 | IsTargetSpecific = 1; |
| 5551 | IsType = 0; |
| 5552 | IsStmt = 0; |
| 5553 | IsKnownToGCC = 1; |
| 5554 | IsSupportedByPragmaAttribute = 1; |
| 5555 | Spellings = NoMicroMipsSpellings; |
| 5556 | } |
| 5557 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5558 | if (!isa<FunctionDecl>(D)) { |
| 5559 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 5560 | << Attr << "functions" ; |
| 5561 | return false; |
| 5562 | } |
| 5563 | return true; |
| 5564 | } |
| 5565 | |
| 5566 | bool existsInTarget(const TargetInfo &Target) const override { |
| 5567 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 5568 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel); |
| 5569 | } |
| 5570 | |
| 5571 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5572 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5573 | } |
| 5574 | |
| 5575 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5576 | D->addAttr(::new (S.Context) NoMicroMipsAttr(S.Context, Attr)); |
| 5577 | return AttributeApplied; |
| 5578 | } |
| 5579 | |
| 5580 | static const ParsedAttrInfoNoMicroMips Instance; |
| 5581 | }; |
| 5582 | const ParsedAttrInfoNoMicroMips ParsedAttrInfoNoMicroMips::Instance; |
| 5583 | static constexpr ParsedAttrInfo::Spelling NoMips16Spellings[] = { |
| 5584 | {AttributeCommonInfo::AS_GNU, "nomips16" }, |
| 5585 | {AttributeCommonInfo::AS_CXX11, "gnu::nomips16" }, |
| 5586 | {AttributeCommonInfo::AS_C2x, "gnu::nomips16" }, |
| 5587 | }; |
| 5588 | struct ParsedAttrInfoNoMips16 final : public ParsedAttrInfo { |
| 5589 | ParsedAttrInfoNoMips16() { |
| 5590 | AttrKind = ParsedAttr::AT_NoMips16; |
| 5591 | NumArgs = 0; |
| 5592 | OptArgs = 0; |
| 5593 | HasCustomParsing = 0; |
| 5594 | IsTargetSpecific = 1; |
| 5595 | IsType = 0; |
| 5596 | IsStmt = 0; |
| 5597 | IsKnownToGCC = 1; |
| 5598 | IsSupportedByPragmaAttribute = 1; |
| 5599 | Spellings = NoMips16Spellings; |
| 5600 | } |
| 5601 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5602 | if (!isa<FunctionDecl>(D)) { |
| 5603 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 5604 | << Attr << "functions" ; |
| 5605 | return false; |
| 5606 | } |
| 5607 | return true; |
| 5608 | } |
| 5609 | |
| 5610 | bool existsInTarget(const TargetInfo &Target) const override { |
| 5611 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 5612 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel); |
| 5613 | } |
| 5614 | |
| 5615 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5616 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5617 | } |
| 5618 | |
| 5619 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5620 | D->addAttr(::new (S.Context) NoMips16Attr(S.Context, Attr)); |
| 5621 | return AttributeApplied; |
| 5622 | } |
| 5623 | |
| 5624 | static const ParsedAttrInfoNoMips16 Instance; |
| 5625 | }; |
| 5626 | const ParsedAttrInfoNoMips16 ParsedAttrInfoNoMips16::Instance; |
| 5627 | static constexpr ParsedAttrInfo::Spelling NoReturnSpellings[] = { |
| 5628 | {AttributeCommonInfo::AS_GNU, "noreturn" }, |
| 5629 | {AttributeCommonInfo::AS_CXX11, "gnu::noreturn" }, |
| 5630 | {AttributeCommonInfo::AS_C2x, "gnu::noreturn" }, |
| 5631 | {AttributeCommonInfo::AS_Declspec, "noreturn" }, |
| 5632 | }; |
| 5633 | struct ParsedAttrInfoNoReturn final : public ParsedAttrInfo { |
| 5634 | ParsedAttrInfoNoReturn() { |
| 5635 | AttrKind = ParsedAttr::AT_NoReturn; |
| 5636 | NumArgs = 0; |
| 5637 | OptArgs = 0; |
| 5638 | HasCustomParsing = 0; |
| 5639 | IsTargetSpecific = 0; |
| 5640 | IsType = 0; |
| 5641 | IsStmt = 0; |
| 5642 | IsKnownToGCC = 1; |
| 5643 | IsSupportedByPragmaAttribute = 0; |
| 5644 | Spellings = NoReturnSpellings; |
| 5645 | } |
| 5646 | static const ParsedAttrInfoNoReturn Instance; |
| 5647 | }; |
| 5648 | const ParsedAttrInfoNoReturn ParsedAttrInfoNoReturn::Instance; |
| 5649 | static constexpr ParsedAttrInfo::Spelling NoSanitizeSpellings[] = { |
| 5650 | {AttributeCommonInfo::AS_GNU, "no_sanitize" }, |
| 5651 | {AttributeCommonInfo::AS_CXX11, "clang::no_sanitize" }, |
| 5652 | {AttributeCommonInfo::AS_C2x, "clang::no_sanitize" }, |
| 5653 | }; |
| 5654 | struct ParsedAttrInfoNoSanitize final : public ParsedAttrInfo { |
| 5655 | ParsedAttrInfoNoSanitize() { |
| 5656 | AttrKind = ParsedAttr::AT_NoSanitize; |
| 5657 | NumArgs = 0; |
| 5658 | OptArgs = 15; |
| 5659 | HasCustomParsing = 0; |
| 5660 | IsTargetSpecific = 0; |
| 5661 | IsType = 0; |
| 5662 | IsStmt = 0; |
| 5663 | IsKnownToGCC = 0; |
| 5664 | IsSupportedByPragmaAttribute = 1; |
| 5665 | Spellings = NoSanitizeSpellings; |
| 5666 | } |
| 5667 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5668 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isGlobalVar(D)) { |
| 5669 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 5670 | << Attr << "functions, Objective-C methods, and global variables" ; |
| 5671 | return false; |
| 5672 | } |
| 5673 | return true; |
| 5674 | } |
| 5675 | |
| 5676 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5677 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5678 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 5679 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
| 5680 | } |
| 5681 | |
| 5682 | static const ParsedAttrInfoNoSanitize Instance; |
| 5683 | }; |
| 5684 | const ParsedAttrInfoNoSanitize ParsedAttrInfoNoSanitize::Instance; |
| 5685 | static constexpr ParsedAttrInfo::Spelling NoSanitizeSpecificSpellings[] = { |
| 5686 | {AttributeCommonInfo::AS_GNU, "no_address_safety_analysis" }, |
| 5687 | {AttributeCommonInfo::AS_CXX11, "gnu::no_address_safety_analysis" }, |
| 5688 | {AttributeCommonInfo::AS_C2x, "gnu::no_address_safety_analysis" }, |
| 5689 | {AttributeCommonInfo::AS_GNU, "no_sanitize_address" }, |
| 5690 | {AttributeCommonInfo::AS_CXX11, "gnu::no_sanitize_address" }, |
| 5691 | {AttributeCommonInfo::AS_C2x, "gnu::no_sanitize_address" }, |
| 5692 | {AttributeCommonInfo::AS_GNU, "no_sanitize_thread" }, |
| 5693 | {AttributeCommonInfo::AS_CXX11, "gnu::no_sanitize_thread" }, |
| 5694 | {AttributeCommonInfo::AS_C2x, "gnu::no_sanitize_thread" }, |
| 5695 | {AttributeCommonInfo::AS_GNU, "no_sanitize_memory" }, |
| 5696 | {AttributeCommonInfo::AS_CXX11, "clang::no_sanitize_memory" }, |
| 5697 | {AttributeCommonInfo::AS_C2x, "clang::no_sanitize_memory" }, |
| 5698 | }; |
| 5699 | struct ParsedAttrInfoNoSanitizeSpecific final : public ParsedAttrInfo { |
| 5700 | ParsedAttrInfoNoSanitizeSpecific() { |
| 5701 | AttrKind = ParsedAttr::AT_NoSanitizeSpecific; |
| 5702 | NumArgs = 0; |
| 5703 | OptArgs = 0; |
| 5704 | HasCustomParsing = 0; |
| 5705 | IsTargetSpecific = 0; |
| 5706 | IsType = 0; |
| 5707 | IsStmt = 0; |
| 5708 | IsKnownToGCC = 1; |
| 5709 | IsSupportedByPragmaAttribute = 1; |
| 5710 | Spellings = NoSanitizeSpecificSpellings; |
| 5711 | } |
| 5712 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5713 | if (!isa<FunctionDecl>(D) && !isGlobalVar(D)) { |
| 5714 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 5715 | << Attr << "functions and global variables" ; |
| 5716 | return false; |
| 5717 | } |
| 5718 | return true; |
| 5719 | } |
| 5720 | |
| 5721 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5722 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5723 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
| 5724 | } |
| 5725 | |
| 5726 | static const ParsedAttrInfoNoSanitizeSpecific Instance; |
| 5727 | }; |
| 5728 | const ParsedAttrInfoNoSanitizeSpecific ParsedAttrInfoNoSanitizeSpecific::Instance; |
| 5729 | static constexpr ParsedAttrInfo::Spelling NoSpeculativeLoadHardeningSpellings[] = { |
| 5730 | {AttributeCommonInfo::AS_GNU, "no_speculative_load_hardening" }, |
| 5731 | {AttributeCommonInfo::AS_CXX11, "clang::no_speculative_load_hardening" }, |
| 5732 | {AttributeCommonInfo::AS_C2x, "clang::no_speculative_load_hardening" }, |
| 5733 | }; |
| 5734 | struct ParsedAttrInfoNoSpeculativeLoadHardening final : public ParsedAttrInfo { |
| 5735 | ParsedAttrInfoNoSpeculativeLoadHardening() { |
| 5736 | AttrKind = ParsedAttr::AT_NoSpeculativeLoadHardening; |
| 5737 | NumArgs = 0; |
| 5738 | OptArgs = 0; |
| 5739 | HasCustomParsing = 0; |
| 5740 | IsTargetSpecific = 0; |
| 5741 | IsType = 0; |
| 5742 | IsStmt = 0; |
| 5743 | IsKnownToGCC = 0; |
| 5744 | IsSupportedByPragmaAttribute = 1; |
| 5745 | Spellings = NoSpeculativeLoadHardeningSpellings; |
| 5746 | } |
| 5747 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5748 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 5749 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 5750 | << Attr << "functions and Objective-C methods" ; |
| 5751 | return false; |
| 5752 | } |
| 5753 | return true; |
| 5754 | } |
| 5755 | |
| 5756 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5757 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5758 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 5759 | } |
| 5760 | |
| 5761 | static const ParsedAttrInfoNoSpeculativeLoadHardening Instance; |
| 5762 | }; |
| 5763 | const ParsedAttrInfoNoSpeculativeLoadHardening ParsedAttrInfoNoSpeculativeLoadHardening::Instance; |
| 5764 | static constexpr ParsedAttrInfo::Spelling NoSplitStackSpellings[] = { |
| 5765 | {AttributeCommonInfo::AS_GNU, "no_split_stack" }, |
| 5766 | {AttributeCommonInfo::AS_CXX11, "gnu::no_split_stack" }, |
| 5767 | {AttributeCommonInfo::AS_C2x, "gnu::no_split_stack" }, |
| 5768 | }; |
| 5769 | struct ParsedAttrInfoNoSplitStack final : public ParsedAttrInfo { |
| 5770 | ParsedAttrInfoNoSplitStack() { |
| 5771 | AttrKind = ParsedAttr::AT_NoSplitStack; |
| 5772 | NumArgs = 0; |
| 5773 | OptArgs = 0; |
| 5774 | HasCustomParsing = 0; |
| 5775 | IsTargetSpecific = 0; |
| 5776 | IsType = 0; |
| 5777 | IsStmt = 0; |
| 5778 | IsKnownToGCC = 1; |
| 5779 | IsSupportedByPragmaAttribute = 1; |
| 5780 | Spellings = NoSplitStackSpellings; |
| 5781 | } |
| 5782 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5783 | if (!isa<FunctionDecl>(D)) { |
| 5784 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 5785 | << Attr << "functions" ; |
| 5786 | return false; |
| 5787 | } |
| 5788 | return true; |
| 5789 | } |
| 5790 | |
| 5791 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5792 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5793 | } |
| 5794 | |
| 5795 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5796 | D->addAttr(::new (S.Context) NoSplitStackAttr(S.Context, Attr)); |
| 5797 | return AttributeApplied; |
| 5798 | } |
| 5799 | |
| 5800 | static const ParsedAttrInfoNoSplitStack Instance; |
| 5801 | }; |
| 5802 | const ParsedAttrInfoNoSplitStack ParsedAttrInfoNoSplitStack::Instance; |
| 5803 | static constexpr ParsedAttrInfo::Spelling NoStackProtectorSpellings[] = { |
| 5804 | {AttributeCommonInfo::AS_GNU, "no_stack_protector" }, |
| 5805 | {AttributeCommonInfo::AS_CXX11, "clang::no_stack_protector" }, |
| 5806 | {AttributeCommonInfo::AS_C2x, "clang::no_stack_protector" }, |
| 5807 | }; |
| 5808 | struct ParsedAttrInfoNoStackProtector final : public ParsedAttrInfo { |
| 5809 | ParsedAttrInfoNoStackProtector() { |
| 5810 | AttrKind = ParsedAttr::AT_NoStackProtector; |
| 5811 | NumArgs = 0; |
| 5812 | OptArgs = 0; |
| 5813 | HasCustomParsing = 0; |
| 5814 | IsTargetSpecific = 0; |
| 5815 | IsType = 0; |
| 5816 | IsStmt = 0; |
| 5817 | IsKnownToGCC = 0; |
| 5818 | IsSupportedByPragmaAttribute = 1; |
| 5819 | Spellings = NoStackProtectorSpellings; |
| 5820 | } |
| 5821 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5822 | if (!isa<FunctionDecl>(D)) { |
| 5823 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5824 | << Attr << "functions" ; |
| 5825 | return false; |
| 5826 | } |
| 5827 | return true; |
| 5828 | } |
| 5829 | |
| 5830 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5831 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5832 | } |
| 5833 | |
| 5834 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5835 | D->addAttr(::new (S.Context) NoStackProtectorAttr(S.Context, Attr)); |
| 5836 | return AttributeApplied; |
| 5837 | } |
| 5838 | |
| 5839 | static const ParsedAttrInfoNoStackProtector Instance; |
| 5840 | }; |
| 5841 | const ParsedAttrInfoNoStackProtector ParsedAttrInfoNoStackProtector::Instance; |
| 5842 | static constexpr ParsedAttrInfo::Spelling NoThreadSafetyAnalysisSpellings[] = { |
| 5843 | {AttributeCommonInfo::AS_GNU, "no_thread_safety_analysis" }, |
| 5844 | {AttributeCommonInfo::AS_CXX11, "clang::no_thread_safety_analysis" }, |
| 5845 | {AttributeCommonInfo::AS_C2x, "clang::no_thread_safety_analysis" }, |
| 5846 | }; |
| 5847 | struct ParsedAttrInfoNoThreadSafetyAnalysis final : public ParsedAttrInfo { |
| 5848 | ParsedAttrInfoNoThreadSafetyAnalysis() { |
| 5849 | AttrKind = ParsedAttr::AT_NoThreadSafetyAnalysis; |
| 5850 | NumArgs = 0; |
| 5851 | OptArgs = 0; |
| 5852 | HasCustomParsing = 0; |
| 5853 | IsTargetSpecific = 0; |
| 5854 | IsType = 0; |
| 5855 | IsStmt = 0; |
| 5856 | IsKnownToGCC = 0; |
| 5857 | IsSupportedByPragmaAttribute = 1; |
| 5858 | Spellings = NoThreadSafetyAnalysisSpellings; |
| 5859 | } |
| 5860 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5861 | if (!isa<FunctionDecl>(D)) { |
| 5862 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5863 | << Attr << "functions" ; |
| 5864 | return false; |
| 5865 | } |
| 5866 | return true; |
| 5867 | } |
| 5868 | |
| 5869 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5870 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 5871 | } |
| 5872 | |
| 5873 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5874 | D->addAttr(::new (S.Context) NoThreadSafetyAnalysisAttr(S.Context, Attr)); |
| 5875 | return AttributeApplied; |
| 5876 | } |
| 5877 | |
| 5878 | static const ParsedAttrInfoNoThreadSafetyAnalysis Instance; |
| 5879 | }; |
| 5880 | const ParsedAttrInfoNoThreadSafetyAnalysis ParsedAttrInfoNoThreadSafetyAnalysis::Instance; |
| 5881 | static constexpr ParsedAttrInfo::Spelling NoThrowSpellings[] = { |
| 5882 | {AttributeCommonInfo::AS_GNU, "nothrow" }, |
| 5883 | {AttributeCommonInfo::AS_CXX11, "gnu::nothrow" }, |
| 5884 | {AttributeCommonInfo::AS_C2x, "gnu::nothrow" }, |
| 5885 | {AttributeCommonInfo::AS_Declspec, "nothrow" }, |
| 5886 | }; |
| 5887 | struct ParsedAttrInfoNoThrow final : public ParsedAttrInfo { |
| 5888 | ParsedAttrInfoNoThrow() { |
| 5889 | AttrKind = ParsedAttr::AT_NoThrow; |
| 5890 | NumArgs = 0; |
| 5891 | OptArgs = 0; |
| 5892 | HasCustomParsing = 0; |
| 5893 | IsTargetSpecific = 0; |
| 5894 | IsType = 0; |
| 5895 | IsStmt = 0; |
| 5896 | IsKnownToGCC = 1; |
| 5897 | IsSupportedByPragmaAttribute = 1; |
| 5898 | Spellings = NoThrowSpellings; |
| 5899 | } |
| 5900 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5901 | if (!isFunctionLike(D)) { |
| 5902 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5903 | << Attr << "functions and function pointers" ; |
| 5904 | return false; |
| 5905 | } |
| 5906 | return true; |
| 5907 | } |
| 5908 | |
| 5909 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 5910 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
| 5911 | } |
| 5912 | |
| 5913 | static const ParsedAttrInfoNoThrow Instance; |
| 5914 | }; |
| 5915 | const ParsedAttrInfoNoThrow ParsedAttrInfoNoThrow::Instance; |
| 5916 | static constexpr ParsedAttrInfo::Spelling NoUniqueAddressSpellings[] = { |
| 5917 | {AttributeCommonInfo::AS_CXX11, "no_unique_address" }, |
| 5918 | }; |
| 5919 | struct ParsedAttrInfoNoUniqueAddress final : public ParsedAttrInfo { |
| 5920 | ParsedAttrInfoNoUniqueAddress() { |
| 5921 | AttrKind = ParsedAttr::AT_NoUniqueAddress; |
| 5922 | NumArgs = 0; |
| 5923 | OptArgs = 0; |
| 5924 | HasCustomParsing = 0; |
| 5925 | IsTargetSpecific = 1; |
| 5926 | IsType = 0; |
| 5927 | IsStmt = 0; |
| 5928 | IsKnownToGCC = 0; |
| 5929 | IsSupportedByPragmaAttribute = 0; |
| 5930 | Spellings = NoUniqueAddressSpellings; |
| 5931 | } |
| 5932 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5933 | if (!isNonBitField(D)) { |
| 5934 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 5935 | << Attr << "non-bit-field non-static data members" ; |
| 5936 | return false; |
| 5937 | } |
| 5938 | return true; |
| 5939 | } |
| 5940 | |
| 5941 | bool existsInTarget(const TargetInfo &Target) const override { |
| 5942 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 5943 | return true && ( Target.getCXXABI().isItaniumFamily() ); |
| 5944 | } |
| 5945 | |
| 5946 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 5947 | D->addAttr(::new (S.Context) NoUniqueAddressAttr(S.Context, Attr)); |
| 5948 | return AttributeApplied; |
| 5949 | } |
| 5950 | |
| 5951 | static const ParsedAttrInfoNoUniqueAddress Instance; |
| 5952 | }; |
| 5953 | const ParsedAttrInfoNoUniqueAddress ParsedAttrInfoNoUniqueAddress::Instance; |
| 5954 | static constexpr ParsedAttrInfo::Spelling NonNullSpellings[] = { |
| 5955 | {AttributeCommonInfo::AS_GNU, "nonnull" }, |
| 5956 | {AttributeCommonInfo::AS_CXX11, "gnu::nonnull" }, |
| 5957 | {AttributeCommonInfo::AS_C2x, "gnu::nonnull" }, |
| 5958 | }; |
| 5959 | struct ParsedAttrInfoNonNull final : public ParsedAttrInfo { |
| 5960 | ParsedAttrInfoNonNull() { |
| 5961 | AttrKind = ParsedAttr::AT_NonNull; |
| 5962 | NumArgs = 0; |
| 5963 | OptArgs = 15; |
| 5964 | HasCustomParsing = 0; |
| 5965 | IsTargetSpecific = 0; |
| 5966 | IsType = 0; |
| 5967 | IsStmt = 0; |
| 5968 | IsKnownToGCC = 1; |
| 5969 | IsSupportedByPragmaAttribute = 0; |
| 5970 | Spellings = NonNullSpellings; |
| 5971 | } |
| 5972 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 5973 | if (!isa<ObjCMethodDecl>(D) && !isHasFunctionProto(D) && !isa<ParmVarDecl>(D)) { |
| 5974 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 5975 | << Attr << "functions, methods, and parameters" ; |
| 5976 | return false; |
| 5977 | } |
| 5978 | return true; |
| 5979 | } |
| 5980 | |
| 5981 | static const ParsedAttrInfoNonNull Instance; |
| 5982 | }; |
| 5983 | const ParsedAttrInfoNonNull ParsedAttrInfoNonNull::Instance; |
| 5984 | static constexpr ParsedAttrInfo::Spelling NotTailCalledSpellings[] = { |
| 5985 | {AttributeCommonInfo::AS_GNU, "not_tail_called" }, |
| 5986 | {AttributeCommonInfo::AS_CXX11, "clang::not_tail_called" }, |
| 5987 | {AttributeCommonInfo::AS_C2x, "clang::not_tail_called" }, |
| 5988 | }; |
| 5989 | struct ParsedAttrInfoNotTailCalled final : public ParsedAttrInfo { |
| 5990 | ParsedAttrInfoNotTailCalled() { |
| 5991 | AttrKind = ParsedAttr::AT_NotTailCalled; |
| 5992 | NumArgs = 0; |
| 5993 | OptArgs = 0; |
| 5994 | HasCustomParsing = 0; |
| 5995 | IsTargetSpecific = 0; |
| 5996 | IsType = 0; |
| 5997 | IsStmt = 0; |
| 5998 | IsKnownToGCC = 0; |
| 5999 | IsSupportedByPragmaAttribute = 1; |
| 6000 | Spellings = NotTailCalledSpellings; |
| 6001 | } |
| 6002 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6003 | if (!isa<FunctionDecl>(D)) { |
| 6004 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 6005 | << Attr << "functions" ; |
| 6006 | return false; |
| 6007 | } |
| 6008 | return true; |
| 6009 | } |
| 6010 | |
| 6011 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6012 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 6013 | } |
| 6014 | |
| 6015 | static const ParsedAttrInfoNotTailCalled Instance; |
| 6016 | }; |
| 6017 | const ParsedAttrInfoNotTailCalled ParsedAttrInfoNotTailCalled::Instance; |
| 6018 | static constexpr ParsedAttrInfo::Spelling OSConsumedSpellings[] = { |
| 6019 | {AttributeCommonInfo::AS_GNU, "os_consumed" }, |
| 6020 | {AttributeCommonInfo::AS_CXX11, "clang::os_consumed" }, |
| 6021 | {AttributeCommonInfo::AS_C2x, "clang::os_consumed" }, |
| 6022 | }; |
| 6023 | struct ParsedAttrInfoOSConsumed final : public ParsedAttrInfo { |
| 6024 | ParsedAttrInfoOSConsumed() { |
| 6025 | AttrKind = ParsedAttr::AT_OSConsumed; |
| 6026 | NumArgs = 0; |
| 6027 | OptArgs = 0; |
| 6028 | HasCustomParsing = 0; |
| 6029 | IsTargetSpecific = 0; |
| 6030 | IsType = 0; |
| 6031 | IsStmt = 0; |
| 6032 | IsKnownToGCC = 0; |
| 6033 | IsSupportedByPragmaAttribute = 1; |
| 6034 | Spellings = OSConsumedSpellings; |
| 6035 | } |
| 6036 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6037 | if (!isa<ParmVarDecl>(D)) { |
| 6038 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 6039 | << Attr << "parameters" ; |
| 6040 | return false; |
| 6041 | } |
| 6042 | return true; |
| 6043 | } |
| 6044 | |
| 6045 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6046 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 6047 | } |
| 6048 | |
| 6049 | static const ParsedAttrInfoOSConsumed Instance; |
| 6050 | }; |
| 6051 | const ParsedAttrInfoOSConsumed ParsedAttrInfoOSConsumed::Instance; |
| 6052 | static constexpr ParsedAttrInfo::Spelling OSConsumesThisSpellings[] = { |
| 6053 | {AttributeCommonInfo::AS_GNU, "os_consumes_this" }, |
| 6054 | {AttributeCommonInfo::AS_CXX11, "clang::os_consumes_this" }, |
| 6055 | {AttributeCommonInfo::AS_C2x, "clang::os_consumes_this" }, |
| 6056 | }; |
| 6057 | struct ParsedAttrInfoOSConsumesThis final : public ParsedAttrInfo { |
| 6058 | ParsedAttrInfoOSConsumesThis() { |
| 6059 | AttrKind = ParsedAttr::AT_OSConsumesThis; |
| 6060 | NumArgs = 0; |
| 6061 | OptArgs = 0; |
| 6062 | HasCustomParsing = 0; |
| 6063 | IsTargetSpecific = 0; |
| 6064 | IsType = 0; |
| 6065 | IsStmt = 0; |
| 6066 | IsKnownToGCC = 0; |
| 6067 | IsSupportedByPragmaAttribute = 0; |
| 6068 | Spellings = OSConsumesThisSpellings; |
| 6069 | } |
| 6070 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6071 | if (!isNonStaticCXXMethod(D)) { |
| 6072 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 6073 | << Attr << "non-static member functions" ; |
| 6074 | return false; |
| 6075 | } |
| 6076 | return true; |
| 6077 | } |
| 6078 | |
| 6079 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 6080 | D->addAttr(::new (S.Context) OSConsumesThisAttr(S.Context, Attr)); |
| 6081 | return AttributeApplied; |
| 6082 | } |
| 6083 | |
| 6084 | static const ParsedAttrInfoOSConsumesThis Instance; |
| 6085 | }; |
| 6086 | const ParsedAttrInfoOSConsumesThis ParsedAttrInfoOSConsumesThis::Instance; |
| 6087 | static constexpr ParsedAttrInfo::Spelling OSReturnsNotRetainedSpellings[] = { |
| 6088 | {AttributeCommonInfo::AS_GNU, "os_returns_not_retained" }, |
| 6089 | {AttributeCommonInfo::AS_CXX11, "clang::os_returns_not_retained" }, |
| 6090 | {AttributeCommonInfo::AS_C2x, "clang::os_returns_not_retained" }, |
| 6091 | }; |
| 6092 | struct ParsedAttrInfoOSReturnsNotRetained final : public ParsedAttrInfo { |
| 6093 | ParsedAttrInfoOSReturnsNotRetained() { |
| 6094 | AttrKind = ParsedAttr::AT_OSReturnsNotRetained; |
| 6095 | NumArgs = 0; |
| 6096 | OptArgs = 0; |
| 6097 | HasCustomParsing = 0; |
| 6098 | IsTargetSpecific = 0; |
| 6099 | IsType = 0; |
| 6100 | IsStmt = 0; |
| 6101 | IsKnownToGCC = 0; |
| 6102 | IsSupportedByPragmaAttribute = 1; |
| 6103 | Spellings = OSReturnsNotRetainedSpellings; |
| 6104 | } |
| 6105 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6106 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D) && !isa<ParmVarDecl>(D)) { |
| 6107 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 6108 | << Attr << "functions, Objective-C methods, Objective-C properties, and parameters" ; |
| 6109 | return false; |
| 6110 | } |
| 6111 | return true; |
| 6112 | } |
| 6113 | |
| 6114 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6115 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 6116 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 6117 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
| 6118 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 6119 | } |
| 6120 | |
| 6121 | static const ParsedAttrInfoOSReturnsNotRetained Instance; |
| 6122 | }; |
| 6123 | const ParsedAttrInfoOSReturnsNotRetained ParsedAttrInfoOSReturnsNotRetained::Instance; |
| 6124 | static constexpr ParsedAttrInfo::Spelling OSReturnsRetainedSpellings[] = { |
| 6125 | {AttributeCommonInfo::AS_GNU, "os_returns_retained" }, |
| 6126 | {AttributeCommonInfo::AS_CXX11, "clang::os_returns_retained" }, |
| 6127 | {AttributeCommonInfo::AS_C2x, "clang::os_returns_retained" }, |
| 6128 | }; |
| 6129 | struct ParsedAttrInfoOSReturnsRetained final : public ParsedAttrInfo { |
| 6130 | ParsedAttrInfoOSReturnsRetained() { |
| 6131 | AttrKind = ParsedAttr::AT_OSReturnsRetained; |
| 6132 | NumArgs = 0; |
| 6133 | OptArgs = 0; |
| 6134 | HasCustomParsing = 0; |
| 6135 | IsTargetSpecific = 0; |
| 6136 | IsType = 0; |
| 6137 | IsStmt = 0; |
| 6138 | IsKnownToGCC = 0; |
| 6139 | IsSupportedByPragmaAttribute = 1; |
| 6140 | Spellings = OSReturnsRetainedSpellings; |
| 6141 | } |
| 6142 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6143 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D) && !isa<ParmVarDecl>(D)) { |
| 6144 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 6145 | << Attr << "functions, Objective-C methods, Objective-C properties, and parameters" ; |
| 6146 | return false; |
| 6147 | } |
| 6148 | return true; |
| 6149 | } |
| 6150 | |
| 6151 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6152 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 6153 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 6154 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
| 6155 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 6156 | } |
| 6157 | |
| 6158 | static const ParsedAttrInfoOSReturnsRetained Instance; |
| 6159 | }; |
| 6160 | const ParsedAttrInfoOSReturnsRetained ParsedAttrInfoOSReturnsRetained::Instance; |
| 6161 | static constexpr ParsedAttrInfo::Spelling OSReturnsRetainedOnNonZeroSpellings[] = { |
| 6162 | {AttributeCommonInfo::AS_GNU, "os_returns_retained_on_non_zero" }, |
| 6163 | {AttributeCommonInfo::AS_CXX11, "clang::os_returns_retained_on_non_zero" }, |
| 6164 | {AttributeCommonInfo::AS_C2x, "clang::os_returns_retained_on_non_zero" }, |
| 6165 | }; |
| 6166 | struct ParsedAttrInfoOSReturnsRetainedOnNonZero final : public ParsedAttrInfo { |
| 6167 | ParsedAttrInfoOSReturnsRetainedOnNonZero() { |
| 6168 | AttrKind = ParsedAttr::AT_OSReturnsRetainedOnNonZero; |
| 6169 | NumArgs = 0; |
| 6170 | OptArgs = 0; |
| 6171 | HasCustomParsing = 0; |
| 6172 | IsTargetSpecific = 0; |
| 6173 | IsType = 0; |
| 6174 | IsStmt = 0; |
| 6175 | IsKnownToGCC = 0; |
| 6176 | IsSupportedByPragmaAttribute = 1; |
| 6177 | Spellings = OSReturnsRetainedOnNonZeroSpellings; |
| 6178 | } |
| 6179 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6180 | if (!isa<ParmVarDecl>(D)) { |
| 6181 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 6182 | << Attr << "parameters" ; |
| 6183 | return false; |
| 6184 | } |
| 6185 | return true; |
| 6186 | } |
| 6187 | |
| 6188 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6189 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 6190 | } |
| 6191 | |
| 6192 | static const ParsedAttrInfoOSReturnsRetainedOnNonZero Instance; |
| 6193 | }; |
| 6194 | const ParsedAttrInfoOSReturnsRetainedOnNonZero ParsedAttrInfoOSReturnsRetainedOnNonZero::Instance; |
| 6195 | static constexpr ParsedAttrInfo::Spelling OSReturnsRetainedOnZeroSpellings[] = { |
| 6196 | {AttributeCommonInfo::AS_GNU, "os_returns_retained_on_zero" }, |
| 6197 | {AttributeCommonInfo::AS_CXX11, "clang::os_returns_retained_on_zero" }, |
| 6198 | {AttributeCommonInfo::AS_C2x, "clang::os_returns_retained_on_zero" }, |
| 6199 | }; |
| 6200 | struct ParsedAttrInfoOSReturnsRetainedOnZero final : public ParsedAttrInfo { |
| 6201 | ParsedAttrInfoOSReturnsRetainedOnZero() { |
| 6202 | AttrKind = ParsedAttr::AT_OSReturnsRetainedOnZero; |
| 6203 | NumArgs = 0; |
| 6204 | OptArgs = 0; |
| 6205 | HasCustomParsing = 0; |
| 6206 | IsTargetSpecific = 0; |
| 6207 | IsType = 0; |
| 6208 | IsStmt = 0; |
| 6209 | IsKnownToGCC = 0; |
| 6210 | IsSupportedByPragmaAttribute = 1; |
| 6211 | Spellings = OSReturnsRetainedOnZeroSpellings; |
| 6212 | } |
| 6213 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6214 | if (!isa<ParmVarDecl>(D)) { |
| 6215 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 6216 | << Attr << "parameters" ; |
| 6217 | return false; |
| 6218 | } |
| 6219 | return true; |
| 6220 | } |
| 6221 | |
| 6222 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6223 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 6224 | } |
| 6225 | |
| 6226 | static const ParsedAttrInfoOSReturnsRetainedOnZero Instance; |
| 6227 | }; |
| 6228 | const ParsedAttrInfoOSReturnsRetainedOnZero ParsedAttrInfoOSReturnsRetainedOnZero::Instance; |
| 6229 | static constexpr ParsedAttrInfo::Spelling ObjCBoxableSpellings[] = { |
| 6230 | {AttributeCommonInfo::AS_GNU, "objc_boxable" }, |
| 6231 | {AttributeCommonInfo::AS_CXX11, "clang::objc_boxable" }, |
| 6232 | {AttributeCommonInfo::AS_C2x, "clang::objc_boxable" }, |
| 6233 | }; |
| 6234 | struct ParsedAttrInfoObjCBoxable final : public ParsedAttrInfo { |
| 6235 | ParsedAttrInfoObjCBoxable() { |
| 6236 | AttrKind = ParsedAttr::AT_ObjCBoxable; |
| 6237 | NumArgs = 0; |
| 6238 | OptArgs = 0; |
| 6239 | HasCustomParsing = 0; |
| 6240 | IsTargetSpecific = 0; |
| 6241 | IsType = 0; |
| 6242 | IsStmt = 0; |
| 6243 | IsKnownToGCC = 0; |
| 6244 | IsSupportedByPragmaAttribute = 1; |
| 6245 | Spellings = ObjCBoxableSpellings; |
| 6246 | } |
| 6247 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6248 | if (!isa<RecordDecl>(D)) { |
| 6249 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6250 | << Attr << "structs, unions, and classes" ; |
| 6251 | return false; |
| 6252 | } |
| 6253 | return true; |
| 6254 | } |
| 6255 | |
| 6256 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6257 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 6258 | } |
| 6259 | |
| 6260 | static const ParsedAttrInfoObjCBoxable Instance; |
| 6261 | }; |
| 6262 | const ParsedAttrInfoObjCBoxable ParsedAttrInfoObjCBoxable::Instance; |
| 6263 | static constexpr ParsedAttrInfo::Spelling ObjCBridgeSpellings[] = { |
| 6264 | {AttributeCommonInfo::AS_GNU, "objc_bridge" }, |
| 6265 | {AttributeCommonInfo::AS_CXX11, "clang::objc_bridge" }, |
| 6266 | {AttributeCommonInfo::AS_C2x, "clang::objc_bridge" }, |
| 6267 | }; |
| 6268 | struct ParsedAttrInfoObjCBridge final : public ParsedAttrInfo { |
| 6269 | ParsedAttrInfoObjCBridge() { |
| 6270 | AttrKind = ParsedAttr::AT_ObjCBridge; |
| 6271 | NumArgs = 1; |
| 6272 | OptArgs = 0; |
| 6273 | HasCustomParsing = 0; |
| 6274 | IsTargetSpecific = 0; |
| 6275 | IsType = 0; |
| 6276 | IsStmt = 0; |
| 6277 | IsKnownToGCC = 0; |
| 6278 | IsSupportedByPragmaAttribute = 1; |
| 6279 | Spellings = ObjCBridgeSpellings; |
| 6280 | } |
| 6281 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6282 | if (!isa<RecordDecl>(D) && !isa<TypedefNameDecl>(D)) { |
| 6283 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6284 | << Attr << "structs, unions, classes, and typedefs" ; |
| 6285 | return false; |
| 6286 | } |
| 6287 | return true; |
| 6288 | } |
| 6289 | |
| 6290 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6291 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 6292 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
| 6293 | } |
| 6294 | |
| 6295 | static const ParsedAttrInfoObjCBridge Instance; |
| 6296 | }; |
| 6297 | const ParsedAttrInfoObjCBridge ParsedAttrInfoObjCBridge::Instance; |
| 6298 | static constexpr ParsedAttrInfo::Spelling ObjCBridgeMutableSpellings[] = { |
| 6299 | {AttributeCommonInfo::AS_GNU, "objc_bridge_mutable" }, |
| 6300 | {AttributeCommonInfo::AS_CXX11, "clang::objc_bridge_mutable" }, |
| 6301 | {AttributeCommonInfo::AS_C2x, "clang::objc_bridge_mutable" }, |
| 6302 | }; |
| 6303 | struct ParsedAttrInfoObjCBridgeMutable final : public ParsedAttrInfo { |
| 6304 | ParsedAttrInfoObjCBridgeMutable() { |
| 6305 | AttrKind = ParsedAttr::AT_ObjCBridgeMutable; |
| 6306 | NumArgs = 1; |
| 6307 | OptArgs = 0; |
| 6308 | HasCustomParsing = 0; |
| 6309 | IsTargetSpecific = 0; |
| 6310 | IsType = 0; |
| 6311 | IsStmt = 0; |
| 6312 | IsKnownToGCC = 0; |
| 6313 | IsSupportedByPragmaAttribute = 1; |
| 6314 | Spellings = ObjCBridgeMutableSpellings; |
| 6315 | } |
| 6316 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6317 | if (!isa<RecordDecl>(D)) { |
| 6318 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6319 | << Attr << "structs, unions, and classes" ; |
| 6320 | return false; |
| 6321 | } |
| 6322 | return true; |
| 6323 | } |
| 6324 | |
| 6325 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6326 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 6327 | } |
| 6328 | |
| 6329 | static const ParsedAttrInfoObjCBridgeMutable Instance; |
| 6330 | }; |
| 6331 | const ParsedAttrInfoObjCBridgeMutable ParsedAttrInfoObjCBridgeMutable::Instance; |
| 6332 | static constexpr ParsedAttrInfo::Spelling ObjCBridgeRelatedSpellings[] = { |
| 6333 | {AttributeCommonInfo::AS_GNU, "objc_bridge_related" }, |
| 6334 | {AttributeCommonInfo::AS_CXX11, "clang::objc_bridge_related" }, |
| 6335 | {AttributeCommonInfo::AS_C2x, "clang::objc_bridge_related" }, |
| 6336 | }; |
| 6337 | struct ParsedAttrInfoObjCBridgeRelated final : public ParsedAttrInfo { |
| 6338 | ParsedAttrInfoObjCBridgeRelated() { |
| 6339 | AttrKind = ParsedAttr::AT_ObjCBridgeRelated; |
| 6340 | NumArgs = 3; |
| 6341 | OptArgs = 0; |
| 6342 | HasCustomParsing = 1; |
| 6343 | IsTargetSpecific = 0; |
| 6344 | IsType = 0; |
| 6345 | IsStmt = 0; |
| 6346 | IsKnownToGCC = 0; |
| 6347 | IsSupportedByPragmaAttribute = 1; |
| 6348 | Spellings = ObjCBridgeRelatedSpellings; |
| 6349 | } |
| 6350 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6351 | if (!isa<RecordDecl>(D)) { |
| 6352 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6353 | << Attr << "structs, unions, and classes" ; |
| 6354 | return false; |
| 6355 | } |
| 6356 | return true; |
| 6357 | } |
| 6358 | |
| 6359 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6360 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 6361 | } |
| 6362 | |
| 6363 | static const ParsedAttrInfoObjCBridgeRelated Instance; |
| 6364 | }; |
| 6365 | const ParsedAttrInfoObjCBridgeRelated ParsedAttrInfoObjCBridgeRelated::Instance; |
| 6366 | static constexpr ParsedAttrInfo::Spelling ObjCClassStubSpellings[] = { |
| 6367 | {AttributeCommonInfo::AS_GNU, "objc_class_stub" }, |
| 6368 | {AttributeCommonInfo::AS_CXX11, "clang::objc_class_stub" }, |
| 6369 | {AttributeCommonInfo::AS_C2x, "clang::objc_class_stub" }, |
| 6370 | }; |
| 6371 | struct ParsedAttrInfoObjCClassStub final : public ParsedAttrInfo { |
| 6372 | ParsedAttrInfoObjCClassStub() { |
| 6373 | AttrKind = ParsedAttr::AT_ObjCClassStub; |
| 6374 | NumArgs = 0; |
| 6375 | OptArgs = 0; |
| 6376 | HasCustomParsing = 0; |
| 6377 | IsTargetSpecific = 0; |
| 6378 | IsType = 0; |
| 6379 | IsStmt = 0; |
| 6380 | IsKnownToGCC = 0; |
| 6381 | IsSupportedByPragmaAttribute = 1; |
| 6382 | Spellings = ObjCClassStubSpellings; |
| 6383 | } |
| 6384 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6385 | if (!isa<ObjCInterfaceDecl>(D)) { |
| 6386 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6387 | << Attr << "Objective-C interfaces" ; |
| 6388 | return false; |
| 6389 | } |
| 6390 | return true; |
| 6391 | } |
| 6392 | |
| 6393 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 6394 | auto &LangOpts = S.LangOpts; |
| 6395 | if ((LangOpts.ObjCRuntime.allowsClassStubs())) |
| 6396 | return true; |
| 6397 | |
| 6398 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 6399 | return false; |
| 6400 | } |
| 6401 | |
| 6402 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6403 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 6404 | } |
| 6405 | |
| 6406 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 6407 | D->addAttr(::new (S.Context) ObjCClassStubAttr(S.Context, Attr)); |
| 6408 | return AttributeApplied; |
| 6409 | } |
| 6410 | |
| 6411 | static const ParsedAttrInfoObjCClassStub Instance; |
| 6412 | }; |
| 6413 | const ParsedAttrInfoObjCClassStub ParsedAttrInfoObjCClassStub::Instance; |
| 6414 | static constexpr ParsedAttrInfo::Spelling ObjCDesignatedInitializerSpellings[] = { |
| 6415 | {AttributeCommonInfo::AS_GNU, "objc_designated_initializer" }, |
| 6416 | {AttributeCommonInfo::AS_CXX11, "clang::objc_designated_initializer" }, |
| 6417 | {AttributeCommonInfo::AS_C2x, "clang::objc_designated_initializer" }, |
| 6418 | }; |
| 6419 | struct ParsedAttrInfoObjCDesignatedInitializer final : public ParsedAttrInfo { |
| 6420 | ParsedAttrInfoObjCDesignatedInitializer() { |
| 6421 | AttrKind = ParsedAttr::AT_ObjCDesignatedInitializer; |
| 6422 | NumArgs = 0; |
| 6423 | OptArgs = 0; |
| 6424 | HasCustomParsing = 0; |
| 6425 | IsTargetSpecific = 0; |
| 6426 | IsType = 0; |
| 6427 | IsStmt = 0; |
| 6428 | IsKnownToGCC = 0; |
| 6429 | IsSupportedByPragmaAttribute = 1; |
| 6430 | Spellings = ObjCDesignatedInitializerSpellings; |
| 6431 | } |
| 6432 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6433 | if (!isa<ObjCMethodDecl>(D)) { |
| 6434 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6435 | << Attr << "Objective-C methods" ; |
| 6436 | return false; |
| 6437 | } |
| 6438 | return true; |
| 6439 | } |
| 6440 | |
| 6441 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6442 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 6443 | } |
| 6444 | |
| 6445 | static const ParsedAttrInfoObjCDesignatedInitializer Instance; |
| 6446 | }; |
| 6447 | const ParsedAttrInfoObjCDesignatedInitializer ParsedAttrInfoObjCDesignatedInitializer::Instance; |
| 6448 | static constexpr ParsedAttrInfo::Spelling ObjCDirectSpellings[] = { |
| 6449 | {AttributeCommonInfo::AS_GNU, "objc_direct" }, |
| 6450 | {AttributeCommonInfo::AS_CXX11, "clang::objc_direct" }, |
| 6451 | {AttributeCommonInfo::AS_C2x, "clang::objc_direct" }, |
| 6452 | }; |
| 6453 | struct ParsedAttrInfoObjCDirect final : public ParsedAttrInfo { |
| 6454 | ParsedAttrInfoObjCDirect() { |
| 6455 | AttrKind = ParsedAttr::AT_ObjCDirect; |
| 6456 | NumArgs = 0; |
| 6457 | OptArgs = 0; |
| 6458 | HasCustomParsing = 0; |
| 6459 | IsTargetSpecific = 0; |
| 6460 | IsType = 0; |
| 6461 | IsStmt = 0; |
| 6462 | IsKnownToGCC = 0; |
| 6463 | IsSupportedByPragmaAttribute = 1; |
| 6464 | Spellings = ObjCDirectSpellings; |
| 6465 | } |
| 6466 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6467 | if (!isa<ObjCMethodDecl>(D)) { |
| 6468 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6469 | << Attr << "Objective-C methods" ; |
| 6470 | return false; |
| 6471 | } |
| 6472 | return true; |
| 6473 | } |
| 6474 | |
| 6475 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 6476 | auto &LangOpts = S.LangOpts; |
| 6477 | if (LangOpts.ObjC) |
| 6478 | return true; |
| 6479 | |
| 6480 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 6481 | return false; |
| 6482 | } |
| 6483 | |
| 6484 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6485 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 6486 | } |
| 6487 | |
| 6488 | static const ParsedAttrInfoObjCDirect Instance; |
| 6489 | }; |
| 6490 | const ParsedAttrInfoObjCDirect ParsedAttrInfoObjCDirect::Instance; |
| 6491 | static constexpr ParsedAttrInfo::Spelling [] = { |
| 6492 | {AttributeCommonInfo::AS_GNU, "objc_direct_members" }, |
| 6493 | {AttributeCommonInfo::AS_CXX11, "clang::objc_direct_members" }, |
| 6494 | {AttributeCommonInfo::AS_C2x, "clang::objc_direct_members" }, |
| 6495 | }; |
| 6496 | struct ParsedAttrInfoObjCDirectMembers final : public ParsedAttrInfo { |
| 6497 | ParsedAttrInfoObjCDirectMembers() { |
| 6498 | AttrKind = ParsedAttr::AT_ObjCDirectMembers; |
| 6499 | NumArgs = 0; |
| 6500 | OptArgs = 0; |
| 6501 | HasCustomParsing = 0; |
| 6502 | IsTargetSpecific = 0; |
| 6503 | IsType = 0; |
| 6504 | IsStmt = 0; |
| 6505 | IsKnownToGCC = 0; |
| 6506 | IsSupportedByPragmaAttribute = 1; |
| 6507 | Spellings = ObjCDirectMembersSpellings; |
| 6508 | } |
| 6509 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6510 | if (!isa<ObjCImplDecl>(D) && !isa<ObjCInterfaceDecl>(D) && !isa<ObjCCategoryDecl>(D)) { |
| 6511 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6512 | << Attr << "Objective-C implementation declarations, Objective-C interfaces, and Objective-C containers" ; |
| 6513 | return false; |
| 6514 | } |
| 6515 | return true; |
| 6516 | } |
| 6517 | |
| 6518 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 6519 | auto &LangOpts = S.LangOpts; |
| 6520 | if (LangOpts.ObjC) |
| 6521 | return true; |
| 6522 | |
| 6523 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 6524 | return false; |
| 6525 | } |
| 6526 | |
| 6527 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6528 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_implementation, /*IsSupported=*/LangOpts.ObjC)); |
| 6529 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 6530 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_category, /*IsSupported=*/LangOpts.ObjC)); |
| 6531 | } |
| 6532 | |
| 6533 | static const ParsedAttrInfoObjCDirectMembers Instance; |
| 6534 | }; |
| 6535 | const ParsedAttrInfoObjCDirectMembers ParsedAttrInfoObjCDirectMembers::Instance; |
| 6536 | static constexpr ParsedAttrInfo::Spelling ObjCExceptionSpellings[] = { |
| 6537 | {AttributeCommonInfo::AS_GNU, "objc_exception" }, |
| 6538 | {AttributeCommonInfo::AS_CXX11, "clang::objc_exception" }, |
| 6539 | {AttributeCommonInfo::AS_C2x, "clang::objc_exception" }, |
| 6540 | }; |
| 6541 | struct ParsedAttrInfoObjCException final : public ParsedAttrInfo { |
| 6542 | ParsedAttrInfoObjCException() { |
| 6543 | AttrKind = ParsedAttr::AT_ObjCException; |
| 6544 | NumArgs = 0; |
| 6545 | OptArgs = 0; |
| 6546 | HasCustomParsing = 0; |
| 6547 | IsTargetSpecific = 0; |
| 6548 | IsType = 0; |
| 6549 | IsStmt = 0; |
| 6550 | IsKnownToGCC = 0; |
| 6551 | IsSupportedByPragmaAttribute = 1; |
| 6552 | Spellings = ObjCExceptionSpellings; |
| 6553 | } |
| 6554 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6555 | if (!isa<ObjCInterfaceDecl>(D)) { |
| 6556 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6557 | << Attr << "Objective-C interfaces" ; |
| 6558 | return false; |
| 6559 | } |
| 6560 | return true; |
| 6561 | } |
| 6562 | |
| 6563 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6564 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 6565 | } |
| 6566 | |
| 6567 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 6568 | D->addAttr(::new (S.Context) ObjCExceptionAttr(S.Context, Attr)); |
| 6569 | return AttributeApplied; |
| 6570 | } |
| 6571 | |
| 6572 | static const ParsedAttrInfoObjCException Instance; |
| 6573 | }; |
| 6574 | const ParsedAttrInfoObjCException ParsedAttrInfoObjCException::Instance; |
| 6575 | static constexpr ParsedAttrInfo::Spelling ObjCExplicitProtocolImplSpellings[] = { |
| 6576 | {AttributeCommonInfo::AS_GNU, "objc_protocol_requires_explicit_implementation" }, |
| 6577 | {AttributeCommonInfo::AS_CXX11, "clang::objc_protocol_requires_explicit_implementation" }, |
| 6578 | {AttributeCommonInfo::AS_C2x, "clang::objc_protocol_requires_explicit_implementation" }, |
| 6579 | }; |
| 6580 | struct ParsedAttrInfoObjCExplicitProtocolImpl final : public ParsedAttrInfo { |
| 6581 | ParsedAttrInfoObjCExplicitProtocolImpl() { |
| 6582 | AttrKind = ParsedAttr::AT_ObjCExplicitProtocolImpl; |
| 6583 | NumArgs = 0; |
| 6584 | OptArgs = 0; |
| 6585 | HasCustomParsing = 0; |
| 6586 | IsTargetSpecific = 0; |
| 6587 | IsType = 0; |
| 6588 | IsStmt = 0; |
| 6589 | IsKnownToGCC = 0; |
| 6590 | IsSupportedByPragmaAttribute = 1; |
| 6591 | Spellings = ObjCExplicitProtocolImplSpellings; |
| 6592 | } |
| 6593 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6594 | if (!isa<ObjCProtocolDecl>(D)) { |
| 6595 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6596 | << Attr << "Objective-C protocols" ; |
| 6597 | return false; |
| 6598 | } |
| 6599 | return true; |
| 6600 | } |
| 6601 | |
| 6602 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6603 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC)); |
| 6604 | } |
| 6605 | |
| 6606 | static const ParsedAttrInfoObjCExplicitProtocolImpl Instance; |
| 6607 | }; |
| 6608 | const ParsedAttrInfoObjCExplicitProtocolImpl ParsedAttrInfoObjCExplicitProtocolImpl::Instance; |
| 6609 | static constexpr ParsedAttrInfo::Spelling ObjCExternallyRetainedSpellings[] = { |
| 6610 | {AttributeCommonInfo::AS_GNU, "objc_externally_retained" }, |
| 6611 | {AttributeCommonInfo::AS_CXX11, "clang::objc_externally_retained" }, |
| 6612 | {AttributeCommonInfo::AS_C2x, "clang::objc_externally_retained" }, |
| 6613 | }; |
| 6614 | struct ParsedAttrInfoObjCExternallyRetained final : public ParsedAttrInfo { |
| 6615 | ParsedAttrInfoObjCExternallyRetained() { |
| 6616 | AttrKind = ParsedAttr::AT_ObjCExternallyRetained; |
| 6617 | NumArgs = 0; |
| 6618 | OptArgs = 0; |
| 6619 | HasCustomParsing = 0; |
| 6620 | IsTargetSpecific = 0; |
| 6621 | IsType = 0; |
| 6622 | IsStmt = 0; |
| 6623 | IsKnownToGCC = 0; |
| 6624 | IsSupportedByPragmaAttribute = 1; |
| 6625 | Spellings = ObjCExternallyRetainedSpellings; |
| 6626 | } |
| 6627 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6628 | if (!isNonParmVar(D) && !isa<FunctionDecl>(D) && !isa<BlockDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 6629 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 6630 | << Attr << "variables, functions, blocks, and Objective-C methods" ; |
| 6631 | return false; |
| 6632 | } |
| 6633 | return true; |
| 6634 | } |
| 6635 | |
| 6636 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 6637 | auto &LangOpts = S.LangOpts; |
| 6638 | if (LangOpts.ObjCAutoRefCount) |
| 6639 | return true; |
| 6640 | |
| 6641 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 6642 | return false; |
| 6643 | } |
| 6644 | |
| 6645 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6646 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_not_is_parameter, /*IsSupported=*/true)); |
| 6647 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 6648 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_block, /*IsSupported=*/LangOpts.Blocks)); |
| 6649 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 6650 | } |
| 6651 | |
| 6652 | static const ParsedAttrInfoObjCExternallyRetained Instance; |
| 6653 | }; |
| 6654 | const ParsedAttrInfoObjCExternallyRetained ParsedAttrInfoObjCExternallyRetained::Instance; |
| 6655 | static constexpr ParsedAttrInfo::Spelling ObjCGCSpellings[] = { |
| 6656 | {AttributeCommonInfo::AS_GNU, "objc_gc" }, |
| 6657 | {AttributeCommonInfo::AS_CXX11, "clang::objc_gc" }, |
| 6658 | {AttributeCommonInfo::AS_C2x, "clang::objc_gc" }, |
| 6659 | }; |
| 6660 | struct ParsedAttrInfoObjCGC final : public ParsedAttrInfo { |
| 6661 | ParsedAttrInfoObjCGC() { |
| 6662 | AttrKind = ParsedAttr::AT_ObjCGC; |
| 6663 | NumArgs = 1; |
| 6664 | OptArgs = 0; |
| 6665 | HasCustomParsing = 0; |
| 6666 | IsTargetSpecific = 0; |
| 6667 | IsType = 1; |
| 6668 | IsStmt = 0; |
| 6669 | IsKnownToGCC = 0; |
| 6670 | IsSupportedByPragmaAttribute = 0; |
| 6671 | Spellings = ObjCGCSpellings; |
| 6672 | } |
| 6673 | static const ParsedAttrInfoObjCGC Instance; |
| 6674 | }; |
| 6675 | const ParsedAttrInfoObjCGC ParsedAttrInfoObjCGC::Instance; |
| 6676 | static constexpr ParsedAttrInfo::Spelling ObjCIndependentClassSpellings[] = { |
| 6677 | {AttributeCommonInfo::AS_GNU, "objc_independent_class" }, |
| 6678 | {AttributeCommonInfo::AS_CXX11, "clang::objc_independent_class" }, |
| 6679 | {AttributeCommonInfo::AS_C2x, "clang::objc_independent_class" }, |
| 6680 | }; |
| 6681 | struct ParsedAttrInfoObjCIndependentClass final : public ParsedAttrInfo { |
| 6682 | ParsedAttrInfoObjCIndependentClass() { |
| 6683 | AttrKind = ParsedAttr::AT_ObjCIndependentClass; |
| 6684 | NumArgs = 0; |
| 6685 | OptArgs = 0; |
| 6686 | HasCustomParsing = 0; |
| 6687 | IsTargetSpecific = 0; |
| 6688 | IsType = 0; |
| 6689 | IsStmt = 0; |
| 6690 | IsKnownToGCC = 0; |
| 6691 | IsSupportedByPragmaAttribute = 0; |
| 6692 | Spellings = ObjCIndependentClassSpellings; |
| 6693 | } |
| 6694 | static const ParsedAttrInfoObjCIndependentClass Instance; |
| 6695 | }; |
| 6696 | const ParsedAttrInfoObjCIndependentClass ParsedAttrInfoObjCIndependentClass::Instance; |
| 6697 | static constexpr ParsedAttrInfo::Spelling ObjCInertUnsafeUnretainedSpellings[] = { |
| 6698 | {AttributeCommonInfo::AS_Keyword, "__unsafe_unretained" }, |
| 6699 | }; |
| 6700 | struct ParsedAttrInfoObjCInertUnsafeUnretained final : public ParsedAttrInfo { |
| 6701 | ParsedAttrInfoObjCInertUnsafeUnretained() { |
| 6702 | AttrKind = ParsedAttr::AT_ObjCInertUnsafeUnretained; |
| 6703 | NumArgs = 0; |
| 6704 | OptArgs = 0; |
| 6705 | HasCustomParsing = 0; |
| 6706 | IsTargetSpecific = 0; |
| 6707 | IsType = 1; |
| 6708 | IsStmt = 0; |
| 6709 | IsKnownToGCC = 0; |
| 6710 | IsSupportedByPragmaAttribute = 0; |
| 6711 | Spellings = ObjCInertUnsafeUnretainedSpellings; |
| 6712 | } |
| 6713 | static const ParsedAttrInfoObjCInertUnsafeUnretained Instance; |
| 6714 | }; |
| 6715 | const ParsedAttrInfoObjCInertUnsafeUnretained ParsedAttrInfoObjCInertUnsafeUnretained::Instance; |
| 6716 | static constexpr ParsedAttrInfo::Spelling ObjCKindOfSpellings[] = { |
| 6717 | {AttributeCommonInfo::AS_Keyword, "__kindof" }, |
| 6718 | }; |
| 6719 | struct ParsedAttrInfoObjCKindOf final : public ParsedAttrInfo { |
| 6720 | ParsedAttrInfoObjCKindOf() { |
| 6721 | AttrKind = ParsedAttr::AT_ObjCKindOf; |
| 6722 | NumArgs = 0; |
| 6723 | OptArgs = 0; |
| 6724 | HasCustomParsing = 0; |
| 6725 | IsTargetSpecific = 0; |
| 6726 | IsType = 1; |
| 6727 | IsStmt = 0; |
| 6728 | IsKnownToGCC = 0; |
| 6729 | IsSupportedByPragmaAttribute = 0; |
| 6730 | Spellings = ObjCKindOfSpellings; |
| 6731 | } |
| 6732 | static const ParsedAttrInfoObjCKindOf Instance; |
| 6733 | }; |
| 6734 | const ParsedAttrInfoObjCKindOf ParsedAttrInfoObjCKindOf::Instance; |
| 6735 | static constexpr ParsedAttrInfo::Spelling ObjCMethodFamilySpellings[] = { |
| 6736 | {AttributeCommonInfo::AS_GNU, "objc_method_family" }, |
| 6737 | {AttributeCommonInfo::AS_CXX11, "clang::objc_method_family" }, |
| 6738 | {AttributeCommonInfo::AS_C2x, "clang::objc_method_family" }, |
| 6739 | }; |
| 6740 | struct ParsedAttrInfoObjCMethodFamily final : public ParsedAttrInfo { |
| 6741 | ParsedAttrInfoObjCMethodFamily() { |
| 6742 | AttrKind = ParsedAttr::AT_ObjCMethodFamily; |
| 6743 | NumArgs = 1; |
| 6744 | OptArgs = 0; |
| 6745 | HasCustomParsing = 0; |
| 6746 | IsTargetSpecific = 0; |
| 6747 | IsType = 0; |
| 6748 | IsStmt = 0; |
| 6749 | IsKnownToGCC = 0; |
| 6750 | IsSupportedByPragmaAttribute = 1; |
| 6751 | Spellings = ObjCMethodFamilySpellings; |
| 6752 | } |
| 6753 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6754 | if (!isa<ObjCMethodDecl>(D)) { |
| 6755 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6756 | << Attr << "Objective-C methods" ; |
| 6757 | return false; |
| 6758 | } |
| 6759 | return true; |
| 6760 | } |
| 6761 | |
| 6762 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6763 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 6764 | } |
| 6765 | |
| 6766 | static const ParsedAttrInfoObjCMethodFamily Instance; |
| 6767 | }; |
| 6768 | const ParsedAttrInfoObjCMethodFamily ParsedAttrInfoObjCMethodFamily::Instance; |
| 6769 | static constexpr ParsedAttrInfo::Spelling ObjCNSObjectSpellings[] = { |
| 6770 | {AttributeCommonInfo::AS_GNU, "NSObject" }, |
| 6771 | {AttributeCommonInfo::AS_CXX11, "clang::NSObject" }, |
| 6772 | {AttributeCommonInfo::AS_C2x, "clang::NSObject" }, |
| 6773 | }; |
| 6774 | struct ParsedAttrInfoObjCNSObject final : public ParsedAttrInfo { |
| 6775 | ParsedAttrInfoObjCNSObject() { |
| 6776 | AttrKind = ParsedAttr::AT_ObjCNSObject; |
| 6777 | NumArgs = 0; |
| 6778 | OptArgs = 0; |
| 6779 | HasCustomParsing = 0; |
| 6780 | IsTargetSpecific = 0; |
| 6781 | IsType = 0; |
| 6782 | IsStmt = 0; |
| 6783 | IsKnownToGCC = 0; |
| 6784 | IsSupportedByPragmaAttribute = 0; |
| 6785 | Spellings = ObjCNSObjectSpellings; |
| 6786 | } |
| 6787 | static const ParsedAttrInfoObjCNSObject Instance; |
| 6788 | }; |
| 6789 | const ParsedAttrInfoObjCNSObject ParsedAttrInfoObjCNSObject::Instance; |
| 6790 | static constexpr ParsedAttrInfo::Spelling ObjCNonLazyClassSpellings[] = { |
| 6791 | {AttributeCommonInfo::AS_GNU, "objc_nonlazy_class" }, |
| 6792 | {AttributeCommonInfo::AS_CXX11, "clang::objc_nonlazy_class" }, |
| 6793 | {AttributeCommonInfo::AS_C2x, "clang::objc_nonlazy_class" }, |
| 6794 | }; |
| 6795 | struct ParsedAttrInfoObjCNonLazyClass final : public ParsedAttrInfo { |
| 6796 | ParsedAttrInfoObjCNonLazyClass() { |
| 6797 | AttrKind = ParsedAttr::AT_ObjCNonLazyClass; |
| 6798 | NumArgs = 0; |
| 6799 | OptArgs = 0; |
| 6800 | HasCustomParsing = 0; |
| 6801 | IsTargetSpecific = 0; |
| 6802 | IsType = 0; |
| 6803 | IsStmt = 0; |
| 6804 | IsKnownToGCC = 0; |
| 6805 | IsSupportedByPragmaAttribute = 1; |
| 6806 | Spellings = ObjCNonLazyClassSpellings; |
| 6807 | } |
| 6808 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6809 | if (!isa<ObjCInterfaceDecl>(D) && !isa<ObjCImplDecl>(D)) { |
| 6810 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6811 | << Attr << "Objective-C interfaces and Objective-C implementation declarations" ; |
| 6812 | return false; |
| 6813 | } |
| 6814 | return true; |
| 6815 | } |
| 6816 | |
| 6817 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 6818 | auto &LangOpts = S.LangOpts; |
| 6819 | if (LangOpts.ObjC) |
| 6820 | return true; |
| 6821 | |
| 6822 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 6823 | return false; |
| 6824 | } |
| 6825 | |
| 6826 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6827 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 6828 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_implementation, /*IsSupported=*/LangOpts.ObjC)); |
| 6829 | } |
| 6830 | |
| 6831 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 6832 | D->addAttr(::new (S.Context) ObjCNonLazyClassAttr(S.Context, Attr)); |
| 6833 | return AttributeApplied; |
| 6834 | } |
| 6835 | |
| 6836 | static const ParsedAttrInfoObjCNonLazyClass Instance; |
| 6837 | }; |
| 6838 | const ParsedAttrInfoObjCNonLazyClass ParsedAttrInfoObjCNonLazyClass::Instance; |
| 6839 | static constexpr ParsedAttrInfo::Spelling ObjCNonRuntimeProtocolSpellings[] = { |
| 6840 | {AttributeCommonInfo::AS_GNU, "objc_non_runtime_protocol" }, |
| 6841 | {AttributeCommonInfo::AS_CXX11, "clang::objc_non_runtime_protocol" }, |
| 6842 | {AttributeCommonInfo::AS_C2x, "clang::objc_non_runtime_protocol" }, |
| 6843 | }; |
| 6844 | struct ParsedAttrInfoObjCNonRuntimeProtocol final : public ParsedAttrInfo { |
| 6845 | ParsedAttrInfoObjCNonRuntimeProtocol() { |
| 6846 | AttrKind = ParsedAttr::AT_ObjCNonRuntimeProtocol; |
| 6847 | NumArgs = 0; |
| 6848 | OptArgs = 0; |
| 6849 | HasCustomParsing = 0; |
| 6850 | IsTargetSpecific = 0; |
| 6851 | IsType = 0; |
| 6852 | IsStmt = 0; |
| 6853 | IsKnownToGCC = 0; |
| 6854 | IsSupportedByPragmaAttribute = 1; |
| 6855 | Spellings = ObjCNonRuntimeProtocolSpellings; |
| 6856 | } |
| 6857 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6858 | if (!isa<ObjCProtocolDecl>(D)) { |
| 6859 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6860 | << Attr << "Objective-C protocols" ; |
| 6861 | return false; |
| 6862 | } |
| 6863 | return true; |
| 6864 | } |
| 6865 | |
| 6866 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 6867 | auto &LangOpts = S.LangOpts; |
| 6868 | if (LangOpts.ObjC) |
| 6869 | return true; |
| 6870 | |
| 6871 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 6872 | return false; |
| 6873 | } |
| 6874 | |
| 6875 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6876 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC)); |
| 6877 | } |
| 6878 | |
| 6879 | static const ParsedAttrInfoObjCNonRuntimeProtocol Instance; |
| 6880 | }; |
| 6881 | const ParsedAttrInfoObjCNonRuntimeProtocol ParsedAttrInfoObjCNonRuntimeProtocol::Instance; |
| 6882 | static constexpr ParsedAttrInfo::Spelling ObjCOwnershipSpellings[] = { |
| 6883 | {AttributeCommonInfo::AS_GNU, "objc_ownership" }, |
| 6884 | {AttributeCommonInfo::AS_CXX11, "clang::objc_ownership" }, |
| 6885 | {AttributeCommonInfo::AS_C2x, "clang::objc_ownership" }, |
| 6886 | }; |
| 6887 | struct ParsedAttrInfoObjCOwnership final : public ParsedAttrInfo { |
| 6888 | ParsedAttrInfoObjCOwnership() { |
| 6889 | AttrKind = ParsedAttr::AT_ObjCOwnership; |
| 6890 | NumArgs = 1; |
| 6891 | OptArgs = 0; |
| 6892 | HasCustomParsing = 0; |
| 6893 | IsTargetSpecific = 0; |
| 6894 | IsType = 1; |
| 6895 | IsStmt = 0; |
| 6896 | IsKnownToGCC = 0; |
| 6897 | IsSupportedByPragmaAttribute = 0; |
| 6898 | Spellings = ObjCOwnershipSpellings; |
| 6899 | } |
| 6900 | static const ParsedAttrInfoObjCOwnership Instance; |
| 6901 | }; |
| 6902 | const ParsedAttrInfoObjCOwnership ParsedAttrInfoObjCOwnership::Instance; |
| 6903 | static constexpr ParsedAttrInfo::Spelling ObjCPreciseLifetimeSpellings[] = { |
| 6904 | {AttributeCommonInfo::AS_GNU, "objc_precise_lifetime" }, |
| 6905 | {AttributeCommonInfo::AS_CXX11, "clang::objc_precise_lifetime" }, |
| 6906 | {AttributeCommonInfo::AS_C2x, "clang::objc_precise_lifetime" }, |
| 6907 | }; |
| 6908 | struct ParsedAttrInfoObjCPreciseLifetime final : public ParsedAttrInfo { |
| 6909 | ParsedAttrInfoObjCPreciseLifetime() { |
| 6910 | AttrKind = ParsedAttr::AT_ObjCPreciseLifetime; |
| 6911 | NumArgs = 0; |
| 6912 | OptArgs = 0; |
| 6913 | HasCustomParsing = 0; |
| 6914 | IsTargetSpecific = 0; |
| 6915 | IsType = 0; |
| 6916 | IsStmt = 0; |
| 6917 | IsKnownToGCC = 0; |
| 6918 | IsSupportedByPragmaAttribute = 1; |
| 6919 | Spellings = ObjCPreciseLifetimeSpellings; |
| 6920 | } |
| 6921 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6922 | if (!isa<VarDecl>(D)) { |
| 6923 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6924 | << Attr << "variables" ; |
| 6925 | return false; |
| 6926 | } |
| 6927 | return true; |
| 6928 | } |
| 6929 | |
| 6930 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6931 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 6932 | } |
| 6933 | |
| 6934 | static const ParsedAttrInfoObjCPreciseLifetime Instance; |
| 6935 | }; |
| 6936 | const ParsedAttrInfoObjCPreciseLifetime ParsedAttrInfoObjCPreciseLifetime::Instance; |
| 6937 | static constexpr ParsedAttrInfo::Spelling ObjCRequiresPropertyDefsSpellings[] = { |
| 6938 | {AttributeCommonInfo::AS_GNU, "objc_requires_property_definitions" }, |
| 6939 | {AttributeCommonInfo::AS_CXX11, "clang::objc_requires_property_definitions" }, |
| 6940 | {AttributeCommonInfo::AS_C2x, "clang::objc_requires_property_definitions" }, |
| 6941 | }; |
| 6942 | struct ParsedAttrInfoObjCRequiresPropertyDefs final : public ParsedAttrInfo { |
| 6943 | ParsedAttrInfoObjCRequiresPropertyDefs() { |
| 6944 | AttrKind = ParsedAttr::AT_ObjCRequiresPropertyDefs; |
| 6945 | NumArgs = 0; |
| 6946 | OptArgs = 0; |
| 6947 | HasCustomParsing = 0; |
| 6948 | IsTargetSpecific = 0; |
| 6949 | IsType = 0; |
| 6950 | IsStmt = 0; |
| 6951 | IsKnownToGCC = 0; |
| 6952 | IsSupportedByPragmaAttribute = 1; |
| 6953 | Spellings = ObjCRequiresPropertyDefsSpellings; |
| 6954 | } |
| 6955 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6956 | if (!isa<ObjCInterfaceDecl>(D)) { |
| 6957 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6958 | << Attr << "Objective-C interfaces" ; |
| 6959 | return false; |
| 6960 | } |
| 6961 | return true; |
| 6962 | } |
| 6963 | |
| 6964 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 6965 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 6966 | } |
| 6967 | |
| 6968 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 6969 | D->addAttr(::new (S.Context) ObjCRequiresPropertyDefsAttr(S.Context, Attr)); |
| 6970 | return AttributeApplied; |
| 6971 | } |
| 6972 | |
| 6973 | static const ParsedAttrInfoObjCRequiresPropertyDefs Instance; |
| 6974 | }; |
| 6975 | const ParsedAttrInfoObjCRequiresPropertyDefs ParsedAttrInfoObjCRequiresPropertyDefs::Instance; |
| 6976 | static constexpr ParsedAttrInfo::Spelling ObjCRequiresSuperSpellings[] = { |
| 6977 | {AttributeCommonInfo::AS_GNU, "objc_requires_super" }, |
| 6978 | {AttributeCommonInfo::AS_CXX11, "clang::objc_requires_super" }, |
| 6979 | {AttributeCommonInfo::AS_C2x, "clang::objc_requires_super" }, |
| 6980 | }; |
| 6981 | struct ParsedAttrInfoObjCRequiresSuper final : public ParsedAttrInfo { |
| 6982 | ParsedAttrInfoObjCRequiresSuper() { |
| 6983 | AttrKind = ParsedAttr::AT_ObjCRequiresSuper; |
| 6984 | NumArgs = 0; |
| 6985 | OptArgs = 0; |
| 6986 | HasCustomParsing = 0; |
| 6987 | IsTargetSpecific = 0; |
| 6988 | IsType = 0; |
| 6989 | IsStmt = 0; |
| 6990 | IsKnownToGCC = 0; |
| 6991 | IsSupportedByPragmaAttribute = 1; |
| 6992 | Spellings = ObjCRequiresSuperSpellings; |
| 6993 | } |
| 6994 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 6995 | if (!isa<ObjCMethodDecl>(D)) { |
| 6996 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 6997 | << Attr << "Objective-C methods" ; |
| 6998 | return false; |
| 6999 | } |
| 7000 | return true; |
| 7001 | } |
| 7002 | |
| 7003 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7004 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 7005 | } |
| 7006 | |
| 7007 | static const ParsedAttrInfoObjCRequiresSuper Instance; |
| 7008 | }; |
| 7009 | const ParsedAttrInfoObjCRequiresSuper ParsedAttrInfoObjCRequiresSuper::Instance; |
| 7010 | static constexpr ParsedAttrInfo::Spelling ObjCReturnsInnerPointerSpellings[] = { |
| 7011 | {AttributeCommonInfo::AS_GNU, "objc_returns_inner_pointer" }, |
| 7012 | {AttributeCommonInfo::AS_CXX11, "clang::objc_returns_inner_pointer" }, |
| 7013 | {AttributeCommonInfo::AS_C2x, "clang::objc_returns_inner_pointer" }, |
| 7014 | }; |
| 7015 | struct ParsedAttrInfoObjCReturnsInnerPointer final : public ParsedAttrInfo { |
| 7016 | ParsedAttrInfoObjCReturnsInnerPointer() { |
| 7017 | AttrKind = ParsedAttr::AT_ObjCReturnsInnerPointer; |
| 7018 | NumArgs = 0; |
| 7019 | OptArgs = 0; |
| 7020 | HasCustomParsing = 0; |
| 7021 | IsTargetSpecific = 0; |
| 7022 | IsType = 0; |
| 7023 | IsStmt = 0; |
| 7024 | IsKnownToGCC = 0; |
| 7025 | IsSupportedByPragmaAttribute = 1; |
| 7026 | Spellings = ObjCReturnsInnerPointerSpellings; |
| 7027 | } |
| 7028 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7029 | if (!isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D)) { |
| 7030 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 7031 | << Attr << "Objective-C methods and Objective-C properties" ; |
| 7032 | return false; |
| 7033 | } |
| 7034 | return true; |
| 7035 | } |
| 7036 | |
| 7037 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7038 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 7039 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
| 7040 | } |
| 7041 | |
| 7042 | static const ParsedAttrInfoObjCReturnsInnerPointer Instance; |
| 7043 | }; |
| 7044 | const ParsedAttrInfoObjCReturnsInnerPointer ParsedAttrInfoObjCReturnsInnerPointer::Instance; |
| 7045 | static constexpr ParsedAttrInfo::Spelling ObjCRootClassSpellings[] = { |
| 7046 | {AttributeCommonInfo::AS_GNU, "objc_root_class" }, |
| 7047 | {AttributeCommonInfo::AS_CXX11, "clang::objc_root_class" }, |
| 7048 | {AttributeCommonInfo::AS_C2x, "clang::objc_root_class" }, |
| 7049 | }; |
| 7050 | struct ParsedAttrInfoObjCRootClass final : public ParsedAttrInfo { |
| 7051 | ParsedAttrInfoObjCRootClass() { |
| 7052 | AttrKind = ParsedAttr::AT_ObjCRootClass; |
| 7053 | NumArgs = 0; |
| 7054 | OptArgs = 0; |
| 7055 | HasCustomParsing = 0; |
| 7056 | IsTargetSpecific = 0; |
| 7057 | IsType = 0; |
| 7058 | IsStmt = 0; |
| 7059 | IsKnownToGCC = 0; |
| 7060 | IsSupportedByPragmaAttribute = 1; |
| 7061 | Spellings = ObjCRootClassSpellings; |
| 7062 | } |
| 7063 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7064 | if (!isa<ObjCInterfaceDecl>(D)) { |
| 7065 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 7066 | << Attr << "Objective-C interfaces" ; |
| 7067 | return false; |
| 7068 | } |
| 7069 | return true; |
| 7070 | } |
| 7071 | |
| 7072 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7073 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 7074 | } |
| 7075 | |
| 7076 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 7077 | D->addAttr(::new (S.Context) ObjCRootClassAttr(S.Context, Attr)); |
| 7078 | return AttributeApplied; |
| 7079 | } |
| 7080 | |
| 7081 | static const ParsedAttrInfoObjCRootClass Instance; |
| 7082 | }; |
| 7083 | const ParsedAttrInfoObjCRootClass ParsedAttrInfoObjCRootClass::Instance; |
| 7084 | static constexpr ParsedAttrInfo::Spelling ObjCRuntimeNameSpellings[] = { |
| 7085 | {AttributeCommonInfo::AS_GNU, "objc_runtime_name" }, |
| 7086 | {AttributeCommonInfo::AS_CXX11, "clang::objc_runtime_name" }, |
| 7087 | {AttributeCommonInfo::AS_C2x, "clang::objc_runtime_name" }, |
| 7088 | }; |
| 7089 | struct ParsedAttrInfoObjCRuntimeName final : public ParsedAttrInfo { |
| 7090 | ParsedAttrInfoObjCRuntimeName() { |
| 7091 | AttrKind = ParsedAttr::AT_ObjCRuntimeName; |
| 7092 | NumArgs = 1; |
| 7093 | OptArgs = 0; |
| 7094 | HasCustomParsing = 0; |
| 7095 | IsTargetSpecific = 0; |
| 7096 | IsType = 0; |
| 7097 | IsStmt = 0; |
| 7098 | IsKnownToGCC = 0; |
| 7099 | IsSupportedByPragmaAttribute = 1; |
| 7100 | Spellings = ObjCRuntimeNameSpellings; |
| 7101 | } |
| 7102 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7103 | if (!isa<ObjCInterfaceDecl>(D) && !isa<ObjCProtocolDecl>(D)) { |
| 7104 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 7105 | << Attr << "Objective-C interfaces and Objective-C protocols" ; |
| 7106 | return false; |
| 7107 | } |
| 7108 | return true; |
| 7109 | } |
| 7110 | |
| 7111 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7112 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 7113 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC)); |
| 7114 | } |
| 7115 | |
| 7116 | static const ParsedAttrInfoObjCRuntimeName Instance; |
| 7117 | }; |
| 7118 | const ParsedAttrInfoObjCRuntimeName ParsedAttrInfoObjCRuntimeName::Instance; |
| 7119 | static constexpr ParsedAttrInfo::Spelling ObjCRuntimeVisibleSpellings[] = { |
| 7120 | {AttributeCommonInfo::AS_GNU, "objc_runtime_visible" }, |
| 7121 | {AttributeCommonInfo::AS_CXX11, "clang::objc_runtime_visible" }, |
| 7122 | {AttributeCommonInfo::AS_C2x, "clang::objc_runtime_visible" }, |
| 7123 | }; |
| 7124 | struct ParsedAttrInfoObjCRuntimeVisible final : public ParsedAttrInfo { |
| 7125 | ParsedAttrInfoObjCRuntimeVisible() { |
| 7126 | AttrKind = ParsedAttr::AT_ObjCRuntimeVisible; |
| 7127 | NumArgs = 0; |
| 7128 | OptArgs = 0; |
| 7129 | HasCustomParsing = 0; |
| 7130 | IsTargetSpecific = 0; |
| 7131 | IsType = 0; |
| 7132 | IsStmt = 0; |
| 7133 | IsKnownToGCC = 0; |
| 7134 | IsSupportedByPragmaAttribute = 1; |
| 7135 | Spellings = ObjCRuntimeVisibleSpellings; |
| 7136 | } |
| 7137 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7138 | if (!isa<ObjCInterfaceDecl>(D)) { |
| 7139 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 7140 | << Attr << "Objective-C interfaces" ; |
| 7141 | return false; |
| 7142 | } |
| 7143 | return true; |
| 7144 | } |
| 7145 | |
| 7146 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7147 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 7148 | } |
| 7149 | |
| 7150 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 7151 | D->addAttr(::new (S.Context) ObjCRuntimeVisibleAttr(S.Context, Attr)); |
| 7152 | return AttributeApplied; |
| 7153 | } |
| 7154 | |
| 7155 | static const ParsedAttrInfoObjCRuntimeVisible Instance; |
| 7156 | }; |
| 7157 | const ParsedAttrInfoObjCRuntimeVisible ParsedAttrInfoObjCRuntimeVisible::Instance; |
| 7158 | static constexpr ParsedAttrInfo::Spelling ObjCSubclassingRestrictedSpellings[] = { |
| 7159 | {AttributeCommonInfo::AS_GNU, "objc_subclassing_restricted" }, |
| 7160 | {AttributeCommonInfo::AS_CXX11, "clang::objc_subclassing_restricted" }, |
| 7161 | {AttributeCommonInfo::AS_C2x, "clang::objc_subclassing_restricted" }, |
| 7162 | }; |
| 7163 | struct ParsedAttrInfoObjCSubclassingRestricted final : public ParsedAttrInfo { |
| 7164 | ParsedAttrInfoObjCSubclassingRestricted() { |
| 7165 | AttrKind = ParsedAttr::AT_ObjCSubclassingRestricted; |
| 7166 | NumArgs = 0; |
| 7167 | OptArgs = 0; |
| 7168 | HasCustomParsing = 0; |
| 7169 | IsTargetSpecific = 0; |
| 7170 | IsType = 0; |
| 7171 | IsStmt = 0; |
| 7172 | IsKnownToGCC = 0; |
| 7173 | IsSupportedByPragmaAttribute = 1; |
| 7174 | Spellings = ObjCSubclassingRestrictedSpellings; |
| 7175 | } |
| 7176 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7177 | if (!isa<ObjCInterfaceDecl>(D)) { |
| 7178 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 7179 | << Attr << "Objective-C interfaces" ; |
| 7180 | return false; |
| 7181 | } |
| 7182 | return true; |
| 7183 | } |
| 7184 | |
| 7185 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7186 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 7187 | } |
| 7188 | |
| 7189 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 7190 | D->addAttr(::new (S.Context) ObjCSubclassingRestrictedAttr(S.Context, Attr)); |
| 7191 | return AttributeApplied; |
| 7192 | } |
| 7193 | |
| 7194 | static const ParsedAttrInfoObjCSubclassingRestricted Instance; |
| 7195 | }; |
| 7196 | const ParsedAttrInfoObjCSubclassingRestricted ParsedAttrInfoObjCSubclassingRestricted::Instance; |
| 7197 | static constexpr ParsedAttrInfo::Spelling OpenCLAccessSpellings[] = { |
| 7198 | {AttributeCommonInfo::AS_Keyword, "__read_only" }, |
| 7199 | {AttributeCommonInfo::AS_Keyword, "read_only" }, |
| 7200 | {AttributeCommonInfo::AS_Keyword, "__write_only" }, |
| 7201 | {AttributeCommonInfo::AS_Keyword, "write_only" }, |
| 7202 | {AttributeCommonInfo::AS_Keyword, "__read_write" }, |
| 7203 | {AttributeCommonInfo::AS_Keyword, "read_write" }, |
| 7204 | }; |
| 7205 | struct ParsedAttrInfoOpenCLAccess final : public ParsedAttrInfo { |
| 7206 | ParsedAttrInfoOpenCLAccess() { |
| 7207 | AttrKind = ParsedAttr::AT_OpenCLAccess; |
| 7208 | NumArgs = 0; |
| 7209 | OptArgs = 0; |
| 7210 | HasCustomParsing = 0; |
| 7211 | IsTargetSpecific = 0; |
| 7212 | IsType = 0; |
| 7213 | IsStmt = 0; |
| 7214 | IsKnownToGCC = 0; |
| 7215 | IsSupportedByPragmaAttribute = 0; |
| 7216 | Spellings = OpenCLAccessSpellings; |
| 7217 | } |
| 7218 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7219 | if (!isa<ParmVarDecl>(D) && !isa<TypedefNameDecl>(D)) { |
| 7220 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 7221 | << Attr << "parameters and typedefs" ; |
| 7222 | return false; |
| 7223 | } |
| 7224 | return true; |
| 7225 | } |
| 7226 | |
| 7227 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 7228 | enum Spelling { |
| 7229 | Keyword_read_only = 0, |
| 7230 | Keyword_write_only = 2, |
| 7231 | Keyword_read_write = 4, |
| 7232 | SpellingNotCalculated = 15 |
| 7233 | |
| 7234 | }; |
| 7235 | |
| 7236 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 7237 | switch (Idx) { |
| 7238 | default: llvm_unreachable("Unknown spelling list index" ); |
| 7239 | case 0: return Keyword_read_only; |
| 7240 | case 1: return Keyword_read_only; |
| 7241 | case 2: return Keyword_write_only; |
| 7242 | case 3: return Keyword_write_only; |
| 7243 | case 4: return Keyword_read_write; |
| 7244 | case 5: return Keyword_read_write; |
| 7245 | } |
| 7246 | } |
| 7247 | |
| 7248 | static const ParsedAttrInfoOpenCLAccess Instance; |
| 7249 | }; |
| 7250 | const ParsedAttrInfoOpenCLAccess ParsedAttrInfoOpenCLAccess::Instance; |
| 7251 | static constexpr ParsedAttrInfo::Spelling OpenCLConstantAddressSpaceSpellings[] = { |
| 7252 | {AttributeCommonInfo::AS_Keyword, "__constant" }, |
| 7253 | {AttributeCommonInfo::AS_Keyword, "constant" }, |
| 7254 | {AttributeCommonInfo::AS_GNU, "opencl_constant" }, |
| 7255 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_constant" }, |
| 7256 | {AttributeCommonInfo::AS_C2x, "clang::opencl_constant" }, |
| 7257 | }; |
| 7258 | struct ParsedAttrInfoOpenCLConstantAddressSpace final : public ParsedAttrInfo { |
| 7259 | ParsedAttrInfoOpenCLConstantAddressSpace() { |
| 7260 | AttrKind = ParsedAttr::AT_OpenCLConstantAddressSpace; |
| 7261 | NumArgs = 0; |
| 7262 | OptArgs = 0; |
| 7263 | HasCustomParsing = 0; |
| 7264 | IsTargetSpecific = 0; |
| 7265 | IsType = 1; |
| 7266 | IsStmt = 0; |
| 7267 | IsKnownToGCC = 0; |
| 7268 | IsSupportedByPragmaAttribute = 0; |
| 7269 | Spellings = OpenCLConstantAddressSpaceSpellings; |
| 7270 | } |
| 7271 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 7272 | enum Spelling { |
| 7273 | Keyword_constant = 0, |
| 7274 | GNU_opencl_constant = 2, |
| 7275 | CXX11_clang_opencl_constant = 3, |
| 7276 | C2x_clang_opencl_constant = 4, |
| 7277 | SpellingNotCalculated = 15 |
| 7278 | |
| 7279 | }; |
| 7280 | |
| 7281 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 7282 | switch (Idx) { |
| 7283 | default: llvm_unreachable("Unknown spelling list index" ); |
| 7284 | case 0: return Keyword_constant; |
| 7285 | case 1: return Keyword_constant; |
| 7286 | case 2: return GNU_opencl_constant; |
| 7287 | case 3: return CXX11_clang_opencl_constant; |
| 7288 | case 4: return C2x_clang_opencl_constant; |
| 7289 | } |
| 7290 | } |
| 7291 | |
| 7292 | static const ParsedAttrInfoOpenCLConstantAddressSpace Instance; |
| 7293 | }; |
| 7294 | const ParsedAttrInfoOpenCLConstantAddressSpace ParsedAttrInfoOpenCLConstantAddressSpace::Instance; |
| 7295 | static constexpr ParsedAttrInfo::Spelling OpenCLGenericAddressSpaceSpellings[] = { |
| 7296 | {AttributeCommonInfo::AS_Keyword, "__generic" }, |
| 7297 | {AttributeCommonInfo::AS_Keyword, "generic" }, |
| 7298 | {AttributeCommonInfo::AS_GNU, "opencl_generic" }, |
| 7299 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_generic" }, |
| 7300 | {AttributeCommonInfo::AS_C2x, "clang::opencl_generic" }, |
| 7301 | }; |
| 7302 | struct ParsedAttrInfoOpenCLGenericAddressSpace final : public ParsedAttrInfo { |
| 7303 | ParsedAttrInfoOpenCLGenericAddressSpace() { |
| 7304 | AttrKind = ParsedAttr::AT_OpenCLGenericAddressSpace; |
| 7305 | NumArgs = 0; |
| 7306 | OptArgs = 0; |
| 7307 | HasCustomParsing = 0; |
| 7308 | IsTargetSpecific = 0; |
| 7309 | IsType = 1; |
| 7310 | IsStmt = 0; |
| 7311 | IsKnownToGCC = 0; |
| 7312 | IsSupportedByPragmaAttribute = 0; |
| 7313 | Spellings = OpenCLGenericAddressSpaceSpellings; |
| 7314 | } |
| 7315 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 7316 | enum Spelling { |
| 7317 | Keyword_generic = 0, |
| 7318 | GNU_opencl_generic = 2, |
| 7319 | CXX11_clang_opencl_generic = 3, |
| 7320 | C2x_clang_opencl_generic = 4, |
| 7321 | SpellingNotCalculated = 15 |
| 7322 | |
| 7323 | }; |
| 7324 | |
| 7325 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 7326 | switch (Idx) { |
| 7327 | default: llvm_unreachable("Unknown spelling list index" ); |
| 7328 | case 0: return Keyword_generic; |
| 7329 | case 1: return Keyword_generic; |
| 7330 | case 2: return GNU_opencl_generic; |
| 7331 | case 3: return CXX11_clang_opencl_generic; |
| 7332 | case 4: return C2x_clang_opencl_generic; |
| 7333 | } |
| 7334 | } |
| 7335 | |
| 7336 | static const ParsedAttrInfoOpenCLGenericAddressSpace Instance; |
| 7337 | }; |
| 7338 | const ParsedAttrInfoOpenCLGenericAddressSpace ParsedAttrInfoOpenCLGenericAddressSpace::Instance; |
| 7339 | static constexpr ParsedAttrInfo::Spelling OpenCLGlobalAddressSpaceSpellings[] = { |
| 7340 | {AttributeCommonInfo::AS_Keyword, "__global" }, |
| 7341 | {AttributeCommonInfo::AS_Keyword, "global" }, |
| 7342 | {AttributeCommonInfo::AS_GNU, "opencl_global" }, |
| 7343 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_global" }, |
| 7344 | {AttributeCommonInfo::AS_C2x, "clang::opencl_global" }, |
| 7345 | }; |
| 7346 | struct ParsedAttrInfoOpenCLGlobalAddressSpace final : public ParsedAttrInfo { |
| 7347 | ParsedAttrInfoOpenCLGlobalAddressSpace() { |
| 7348 | AttrKind = ParsedAttr::AT_OpenCLGlobalAddressSpace; |
| 7349 | NumArgs = 0; |
| 7350 | OptArgs = 0; |
| 7351 | HasCustomParsing = 0; |
| 7352 | IsTargetSpecific = 0; |
| 7353 | IsType = 1; |
| 7354 | IsStmt = 0; |
| 7355 | IsKnownToGCC = 0; |
| 7356 | IsSupportedByPragmaAttribute = 0; |
| 7357 | Spellings = OpenCLGlobalAddressSpaceSpellings; |
| 7358 | } |
| 7359 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 7360 | enum Spelling { |
| 7361 | Keyword_global = 0, |
| 7362 | GNU_opencl_global = 2, |
| 7363 | CXX11_clang_opencl_global = 3, |
| 7364 | C2x_clang_opencl_global = 4, |
| 7365 | SpellingNotCalculated = 15 |
| 7366 | |
| 7367 | }; |
| 7368 | |
| 7369 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 7370 | switch (Idx) { |
| 7371 | default: llvm_unreachable("Unknown spelling list index" ); |
| 7372 | case 0: return Keyword_global; |
| 7373 | case 1: return Keyword_global; |
| 7374 | case 2: return GNU_opencl_global; |
| 7375 | case 3: return CXX11_clang_opencl_global; |
| 7376 | case 4: return C2x_clang_opencl_global; |
| 7377 | } |
| 7378 | } |
| 7379 | |
| 7380 | static const ParsedAttrInfoOpenCLGlobalAddressSpace Instance; |
| 7381 | }; |
| 7382 | const ParsedAttrInfoOpenCLGlobalAddressSpace ParsedAttrInfoOpenCLGlobalAddressSpace::Instance; |
| 7383 | static constexpr ParsedAttrInfo::Spelling OpenCLGlobalDeviceAddressSpaceSpellings[] = { |
| 7384 | {AttributeCommonInfo::AS_GNU, "opencl_global_device" }, |
| 7385 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_global_device" }, |
| 7386 | {AttributeCommonInfo::AS_C2x, "clang::opencl_global_device" }, |
| 7387 | }; |
| 7388 | struct ParsedAttrInfoOpenCLGlobalDeviceAddressSpace final : public ParsedAttrInfo { |
| 7389 | ParsedAttrInfoOpenCLGlobalDeviceAddressSpace() { |
| 7390 | AttrKind = ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace; |
| 7391 | NumArgs = 0; |
| 7392 | OptArgs = 0; |
| 7393 | HasCustomParsing = 0; |
| 7394 | IsTargetSpecific = 0; |
| 7395 | IsType = 1; |
| 7396 | IsStmt = 0; |
| 7397 | IsKnownToGCC = 0; |
| 7398 | IsSupportedByPragmaAttribute = 0; |
| 7399 | Spellings = OpenCLGlobalDeviceAddressSpaceSpellings; |
| 7400 | } |
| 7401 | static const ParsedAttrInfoOpenCLGlobalDeviceAddressSpace Instance; |
| 7402 | }; |
| 7403 | const ParsedAttrInfoOpenCLGlobalDeviceAddressSpace ParsedAttrInfoOpenCLGlobalDeviceAddressSpace::Instance; |
| 7404 | static constexpr ParsedAttrInfo::Spelling OpenCLGlobalHostAddressSpaceSpellings[] = { |
| 7405 | {AttributeCommonInfo::AS_GNU, "opencl_global_host" }, |
| 7406 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_global_host" }, |
| 7407 | {AttributeCommonInfo::AS_C2x, "clang::opencl_global_host" }, |
| 7408 | }; |
| 7409 | struct ParsedAttrInfoOpenCLGlobalHostAddressSpace final : public ParsedAttrInfo { |
| 7410 | ParsedAttrInfoOpenCLGlobalHostAddressSpace() { |
| 7411 | AttrKind = ParsedAttr::AT_OpenCLGlobalHostAddressSpace; |
| 7412 | NumArgs = 0; |
| 7413 | OptArgs = 0; |
| 7414 | HasCustomParsing = 0; |
| 7415 | IsTargetSpecific = 0; |
| 7416 | IsType = 1; |
| 7417 | IsStmt = 0; |
| 7418 | IsKnownToGCC = 0; |
| 7419 | IsSupportedByPragmaAttribute = 0; |
| 7420 | Spellings = OpenCLGlobalHostAddressSpaceSpellings; |
| 7421 | } |
| 7422 | static const ParsedAttrInfoOpenCLGlobalHostAddressSpace Instance; |
| 7423 | }; |
| 7424 | const ParsedAttrInfoOpenCLGlobalHostAddressSpace ParsedAttrInfoOpenCLGlobalHostAddressSpace::Instance; |
| 7425 | static constexpr ParsedAttrInfo::Spelling OpenCLIntelReqdSubGroupSizeSpellings[] = { |
| 7426 | {AttributeCommonInfo::AS_GNU, "intel_reqd_sub_group_size" }, |
| 7427 | }; |
| 7428 | struct ParsedAttrInfoOpenCLIntelReqdSubGroupSize final : public ParsedAttrInfo { |
| 7429 | ParsedAttrInfoOpenCLIntelReqdSubGroupSize() { |
| 7430 | AttrKind = ParsedAttr::AT_OpenCLIntelReqdSubGroupSize; |
| 7431 | NumArgs = 1; |
| 7432 | OptArgs = 0; |
| 7433 | HasCustomParsing = 0; |
| 7434 | IsTargetSpecific = 0; |
| 7435 | IsType = 0; |
| 7436 | IsStmt = 0; |
| 7437 | IsKnownToGCC = 0; |
| 7438 | IsSupportedByPragmaAttribute = 1; |
| 7439 | Spellings = OpenCLIntelReqdSubGroupSizeSpellings; |
| 7440 | } |
| 7441 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7442 | if (!isa<FunctionDecl>(D)) { |
| 7443 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 7444 | << Attr << "functions" ; |
| 7445 | return false; |
| 7446 | } |
| 7447 | return true; |
| 7448 | } |
| 7449 | |
| 7450 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7451 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 7452 | } |
| 7453 | |
| 7454 | static const ParsedAttrInfoOpenCLIntelReqdSubGroupSize Instance; |
| 7455 | }; |
| 7456 | const ParsedAttrInfoOpenCLIntelReqdSubGroupSize ParsedAttrInfoOpenCLIntelReqdSubGroupSize::Instance; |
| 7457 | static constexpr ParsedAttrInfo::Spelling OpenCLKernelSpellings[] = { |
| 7458 | {AttributeCommonInfo::AS_Keyword, "__kernel" }, |
| 7459 | {AttributeCommonInfo::AS_Keyword, "kernel" }, |
| 7460 | }; |
| 7461 | struct ParsedAttrInfoOpenCLKernel final : public ParsedAttrInfo { |
| 7462 | ParsedAttrInfoOpenCLKernel() { |
| 7463 | AttrKind = ParsedAttr::AT_OpenCLKernel; |
| 7464 | NumArgs = 0; |
| 7465 | OptArgs = 0; |
| 7466 | HasCustomParsing = 0; |
| 7467 | IsTargetSpecific = 0; |
| 7468 | IsType = 0; |
| 7469 | IsStmt = 0; |
| 7470 | IsKnownToGCC = 0; |
| 7471 | IsSupportedByPragmaAttribute = 0; |
| 7472 | Spellings = OpenCLKernelSpellings; |
| 7473 | } |
| 7474 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7475 | if (!isa<FunctionDecl>(D)) { |
| 7476 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 7477 | << Attr << "functions" ; |
| 7478 | return false; |
| 7479 | } |
| 7480 | return true; |
| 7481 | } |
| 7482 | |
| 7483 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 7484 | D->addAttr(::new (S.Context) OpenCLKernelAttr(S.Context, Attr)); |
| 7485 | return AttributeApplied; |
| 7486 | } |
| 7487 | |
| 7488 | static const ParsedAttrInfoOpenCLKernel Instance; |
| 7489 | }; |
| 7490 | const ParsedAttrInfoOpenCLKernel ParsedAttrInfoOpenCLKernel::Instance; |
| 7491 | static constexpr ParsedAttrInfo::Spelling OpenCLLocalAddressSpaceSpellings[] = { |
| 7492 | {AttributeCommonInfo::AS_Keyword, "__local" }, |
| 7493 | {AttributeCommonInfo::AS_Keyword, "local" }, |
| 7494 | {AttributeCommonInfo::AS_GNU, "opencl_local" }, |
| 7495 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_local" }, |
| 7496 | {AttributeCommonInfo::AS_C2x, "clang::opencl_local" }, |
| 7497 | }; |
| 7498 | struct ParsedAttrInfoOpenCLLocalAddressSpace final : public ParsedAttrInfo { |
| 7499 | ParsedAttrInfoOpenCLLocalAddressSpace() { |
| 7500 | AttrKind = ParsedAttr::AT_OpenCLLocalAddressSpace; |
| 7501 | NumArgs = 0; |
| 7502 | OptArgs = 0; |
| 7503 | HasCustomParsing = 0; |
| 7504 | IsTargetSpecific = 0; |
| 7505 | IsType = 1; |
| 7506 | IsStmt = 0; |
| 7507 | IsKnownToGCC = 0; |
| 7508 | IsSupportedByPragmaAttribute = 0; |
| 7509 | Spellings = OpenCLLocalAddressSpaceSpellings; |
| 7510 | } |
| 7511 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 7512 | enum Spelling { |
| 7513 | Keyword_local = 0, |
| 7514 | GNU_opencl_local = 2, |
| 7515 | CXX11_clang_opencl_local = 3, |
| 7516 | C2x_clang_opencl_local = 4, |
| 7517 | SpellingNotCalculated = 15 |
| 7518 | |
| 7519 | }; |
| 7520 | |
| 7521 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 7522 | switch (Idx) { |
| 7523 | default: llvm_unreachable("Unknown spelling list index" ); |
| 7524 | case 0: return Keyword_local; |
| 7525 | case 1: return Keyword_local; |
| 7526 | case 2: return GNU_opencl_local; |
| 7527 | case 3: return CXX11_clang_opencl_local; |
| 7528 | case 4: return C2x_clang_opencl_local; |
| 7529 | } |
| 7530 | } |
| 7531 | |
| 7532 | static const ParsedAttrInfoOpenCLLocalAddressSpace Instance; |
| 7533 | }; |
| 7534 | const ParsedAttrInfoOpenCLLocalAddressSpace ParsedAttrInfoOpenCLLocalAddressSpace::Instance; |
| 7535 | static constexpr ParsedAttrInfo::Spelling OpenCLNoSVMSpellings[] = { |
| 7536 | {AttributeCommonInfo::AS_GNU, "nosvm" }, |
| 7537 | }; |
| 7538 | struct ParsedAttrInfoOpenCLNoSVM final : public ParsedAttrInfo { |
| 7539 | ParsedAttrInfoOpenCLNoSVM() { |
| 7540 | AttrKind = ParsedAttr::AT_OpenCLNoSVM; |
| 7541 | NumArgs = 0; |
| 7542 | OptArgs = 0; |
| 7543 | HasCustomParsing = 0; |
| 7544 | IsTargetSpecific = 0; |
| 7545 | IsType = 0; |
| 7546 | IsStmt = 0; |
| 7547 | IsKnownToGCC = 0; |
| 7548 | IsSupportedByPragmaAttribute = 1; |
| 7549 | Spellings = OpenCLNoSVMSpellings; |
| 7550 | } |
| 7551 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7552 | if (!isa<VarDecl>(D)) { |
| 7553 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 7554 | << Attr << "variables" ; |
| 7555 | return false; |
| 7556 | } |
| 7557 | return true; |
| 7558 | } |
| 7559 | |
| 7560 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 7561 | auto &LangOpts = S.LangOpts; |
| 7562 | if (LangOpts.OpenCL) |
| 7563 | return true; |
| 7564 | |
| 7565 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 7566 | return false; |
| 7567 | } |
| 7568 | |
| 7569 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7570 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 7571 | } |
| 7572 | |
| 7573 | static const ParsedAttrInfoOpenCLNoSVM Instance; |
| 7574 | }; |
| 7575 | const ParsedAttrInfoOpenCLNoSVM ParsedAttrInfoOpenCLNoSVM::Instance; |
| 7576 | static constexpr ParsedAttrInfo::Spelling OpenCLPrivateAddressSpaceSpellings[] = { |
| 7577 | {AttributeCommonInfo::AS_Keyword, "__private" }, |
| 7578 | {AttributeCommonInfo::AS_Keyword, "private" }, |
| 7579 | {AttributeCommonInfo::AS_GNU, "opencl_private" }, |
| 7580 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_private" }, |
| 7581 | {AttributeCommonInfo::AS_C2x, "clang::opencl_private" }, |
| 7582 | }; |
| 7583 | struct ParsedAttrInfoOpenCLPrivateAddressSpace final : public ParsedAttrInfo { |
| 7584 | ParsedAttrInfoOpenCLPrivateAddressSpace() { |
| 7585 | AttrKind = ParsedAttr::AT_OpenCLPrivateAddressSpace; |
| 7586 | NumArgs = 0; |
| 7587 | OptArgs = 0; |
| 7588 | HasCustomParsing = 0; |
| 7589 | IsTargetSpecific = 0; |
| 7590 | IsType = 1; |
| 7591 | IsStmt = 0; |
| 7592 | IsKnownToGCC = 0; |
| 7593 | IsSupportedByPragmaAttribute = 0; |
| 7594 | Spellings = OpenCLPrivateAddressSpaceSpellings; |
| 7595 | } |
| 7596 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 7597 | enum Spelling { |
| 7598 | Keyword_private = 0, |
| 7599 | GNU_opencl_private = 2, |
| 7600 | CXX11_clang_opencl_private = 3, |
| 7601 | C2x_clang_opencl_private = 4, |
| 7602 | SpellingNotCalculated = 15 |
| 7603 | |
| 7604 | }; |
| 7605 | |
| 7606 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 7607 | switch (Idx) { |
| 7608 | default: llvm_unreachable("Unknown spelling list index" ); |
| 7609 | case 0: return Keyword_private; |
| 7610 | case 1: return Keyword_private; |
| 7611 | case 2: return GNU_opencl_private; |
| 7612 | case 3: return CXX11_clang_opencl_private; |
| 7613 | case 4: return C2x_clang_opencl_private; |
| 7614 | } |
| 7615 | } |
| 7616 | |
| 7617 | static const ParsedAttrInfoOpenCLPrivateAddressSpace Instance; |
| 7618 | }; |
| 7619 | const ParsedAttrInfoOpenCLPrivateAddressSpace ParsedAttrInfoOpenCLPrivateAddressSpace::Instance; |
| 7620 | static constexpr ParsedAttrInfo::Spelling OpenCLUnrollHintSpellings[] = { |
| 7621 | {AttributeCommonInfo::AS_GNU, "opencl_unroll_hint" }, |
| 7622 | }; |
| 7623 | struct ParsedAttrInfoOpenCLUnrollHint final : public ParsedAttrInfo { |
| 7624 | ParsedAttrInfoOpenCLUnrollHint() { |
| 7625 | AttrKind = ParsedAttr::AT_OpenCLUnrollHint; |
| 7626 | NumArgs = 1; |
| 7627 | OptArgs = 0; |
| 7628 | HasCustomParsing = 0; |
| 7629 | IsTargetSpecific = 0; |
| 7630 | IsType = 0; |
| 7631 | IsStmt = 0; |
| 7632 | IsKnownToGCC = 0; |
| 7633 | IsSupportedByPragmaAttribute = 0; |
| 7634 | Spellings = OpenCLUnrollHintSpellings; |
| 7635 | } |
| 7636 | static const ParsedAttrInfoOpenCLUnrollHint Instance; |
| 7637 | }; |
| 7638 | const ParsedAttrInfoOpenCLUnrollHint ParsedAttrInfoOpenCLUnrollHint::Instance; |
| 7639 | static constexpr ParsedAttrInfo::Spelling OptimizeNoneSpellings[] = { |
| 7640 | {AttributeCommonInfo::AS_GNU, "optnone" }, |
| 7641 | {AttributeCommonInfo::AS_CXX11, "clang::optnone" }, |
| 7642 | {AttributeCommonInfo::AS_C2x, "clang::optnone" }, |
| 7643 | }; |
| 7644 | struct ParsedAttrInfoOptimizeNone final : public ParsedAttrInfo { |
| 7645 | ParsedAttrInfoOptimizeNone() { |
| 7646 | AttrKind = ParsedAttr::AT_OptimizeNone; |
| 7647 | NumArgs = 0; |
| 7648 | OptArgs = 0; |
| 7649 | HasCustomParsing = 0; |
| 7650 | IsTargetSpecific = 0; |
| 7651 | IsType = 0; |
| 7652 | IsStmt = 0; |
| 7653 | IsKnownToGCC = 0; |
| 7654 | IsSupportedByPragmaAttribute = 1; |
| 7655 | Spellings = OptimizeNoneSpellings; |
| 7656 | } |
| 7657 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7658 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 7659 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 7660 | << Attr << "functions and Objective-C methods" ; |
| 7661 | return false; |
| 7662 | } |
| 7663 | return true; |
| 7664 | } |
| 7665 | |
| 7666 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7667 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 7668 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 7669 | } |
| 7670 | |
| 7671 | static const ParsedAttrInfoOptimizeNone Instance; |
| 7672 | }; |
| 7673 | const ParsedAttrInfoOptimizeNone ParsedAttrInfoOptimizeNone::Instance; |
| 7674 | static constexpr ParsedAttrInfo::Spelling OverloadableSpellings[] = { |
| 7675 | {AttributeCommonInfo::AS_GNU, "overloadable" }, |
| 7676 | {AttributeCommonInfo::AS_CXX11, "clang::overloadable" }, |
| 7677 | {AttributeCommonInfo::AS_C2x, "clang::overloadable" }, |
| 7678 | }; |
| 7679 | struct ParsedAttrInfoOverloadable final : public ParsedAttrInfo { |
| 7680 | ParsedAttrInfoOverloadable() { |
| 7681 | AttrKind = ParsedAttr::AT_Overloadable; |
| 7682 | NumArgs = 0; |
| 7683 | OptArgs = 0; |
| 7684 | HasCustomParsing = 0; |
| 7685 | IsTargetSpecific = 0; |
| 7686 | IsType = 0; |
| 7687 | IsStmt = 0; |
| 7688 | IsKnownToGCC = 0; |
| 7689 | IsSupportedByPragmaAttribute = 1; |
| 7690 | Spellings = OverloadableSpellings; |
| 7691 | } |
| 7692 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7693 | if (!isa<FunctionDecl>(D)) { |
| 7694 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 7695 | << Attr << "functions" ; |
| 7696 | return false; |
| 7697 | } |
| 7698 | return true; |
| 7699 | } |
| 7700 | |
| 7701 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7702 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 7703 | } |
| 7704 | |
| 7705 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 7706 | D->addAttr(::new (S.Context) OverloadableAttr(S.Context, Attr)); |
| 7707 | return AttributeApplied; |
| 7708 | } |
| 7709 | |
| 7710 | static const ParsedAttrInfoOverloadable Instance; |
| 7711 | }; |
| 7712 | const ParsedAttrInfoOverloadable ParsedAttrInfoOverloadable::Instance; |
| 7713 | static constexpr ParsedAttrInfo::Spelling OwnerSpellings[] = { |
| 7714 | {AttributeCommonInfo::AS_CXX11, "gsl::Owner" }, |
| 7715 | }; |
| 7716 | struct ParsedAttrInfoOwner final : public ParsedAttrInfo { |
| 7717 | ParsedAttrInfoOwner() { |
| 7718 | AttrKind = ParsedAttr::AT_Owner; |
| 7719 | NumArgs = 0; |
| 7720 | OptArgs = 1; |
| 7721 | HasCustomParsing = 0; |
| 7722 | IsTargetSpecific = 0; |
| 7723 | IsType = 0; |
| 7724 | IsStmt = 0; |
| 7725 | IsKnownToGCC = 0; |
| 7726 | IsSupportedByPragmaAttribute = 1; |
| 7727 | Spellings = OwnerSpellings; |
| 7728 | } |
| 7729 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7730 | if (!isStruct(D)) { |
| 7731 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 7732 | << Attr << "structs" ; |
| 7733 | return false; |
| 7734 | } |
| 7735 | return true; |
| 7736 | } |
| 7737 | |
| 7738 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7739 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record_not_is_union, /*IsSupported=*/true)); |
| 7740 | } |
| 7741 | |
| 7742 | static const ParsedAttrInfoOwner Instance; |
| 7743 | }; |
| 7744 | const ParsedAttrInfoOwner ParsedAttrInfoOwner::Instance; |
| 7745 | static constexpr ParsedAttrInfo::Spelling OwnershipSpellings[] = { |
| 7746 | {AttributeCommonInfo::AS_GNU, "ownership_holds" }, |
| 7747 | {AttributeCommonInfo::AS_CXX11, "clang::ownership_holds" }, |
| 7748 | {AttributeCommonInfo::AS_C2x, "clang::ownership_holds" }, |
| 7749 | {AttributeCommonInfo::AS_GNU, "ownership_returns" }, |
| 7750 | {AttributeCommonInfo::AS_CXX11, "clang::ownership_returns" }, |
| 7751 | {AttributeCommonInfo::AS_C2x, "clang::ownership_returns" }, |
| 7752 | {AttributeCommonInfo::AS_GNU, "ownership_takes" }, |
| 7753 | {AttributeCommonInfo::AS_CXX11, "clang::ownership_takes" }, |
| 7754 | {AttributeCommonInfo::AS_C2x, "clang::ownership_takes" }, |
| 7755 | }; |
| 7756 | struct ParsedAttrInfoOwnership final : public ParsedAttrInfo { |
| 7757 | ParsedAttrInfoOwnership() { |
| 7758 | AttrKind = ParsedAttr::AT_Ownership; |
| 7759 | NumArgs = 1; |
| 7760 | OptArgs = 15; |
| 7761 | HasCustomParsing = 0; |
| 7762 | IsTargetSpecific = 0; |
| 7763 | IsType = 0; |
| 7764 | IsStmt = 0; |
| 7765 | IsKnownToGCC = 0; |
| 7766 | IsSupportedByPragmaAttribute = 0; |
| 7767 | Spellings = OwnershipSpellings; |
| 7768 | } |
| 7769 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7770 | if (!isHasFunctionProto(D)) { |
| 7771 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 7772 | << Attr << "non-K&R-style functions" ; |
| 7773 | return false; |
| 7774 | } |
| 7775 | return true; |
| 7776 | } |
| 7777 | |
| 7778 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 7779 | enum Spelling { |
| 7780 | GNU_ownership_holds = 0, |
| 7781 | CXX11_clang_ownership_holds = 1, |
| 7782 | C2x_clang_ownership_holds = 2, |
| 7783 | GNU_ownership_returns = 3, |
| 7784 | CXX11_clang_ownership_returns = 4, |
| 7785 | C2x_clang_ownership_returns = 5, |
| 7786 | GNU_ownership_takes = 6, |
| 7787 | CXX11_clang_ownership_takes = 7, |
| 7788 | C2x_clang_ownership_takes = 8, |
| 7789 | SpellingNotCalculated = 15 |
| 7790 | |
| 7791 | }; |
| 7792 | |
| 7793 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 7794 | switch (Idx) { |
| 7795 | default: llvm_unreachable("Unknown spelling list index" ); |
| 7796 | case 0: return GNU_ownership_holds; |
| 7797 | case 1: return CXX11_clang_ownership_holds; |
| 7798 | case 2: return C2x_clang_ownership_holds; |
| 7799 | case 3: return GNU_ownership_returns; |
| 7800 | case 4: return CXX11_clang_ownership_returns; |
| 7801 | case 5: return C2x_clang_ownership_returns; |
| 7802 | case 6: return GNU_ownership_takes; |
| 7803 | case 7: return CXX11_clang_ownership_takes; |
| 7804 | case 8: return C2x_clang_ownership_takes; |
| 7805 | } |
| 7806 | } |
| 7807 | |
| 7808 | static const ParsedAttrInfoOwnership Instance; |
| 7809 | }; |
| 7810 | const ParsedAttrInfoOwnership ParsedAttrInfoOwnership::Instance; |
| 7811 | static constexpr ParsedAttrInfo::Spelling PackedSpellings[] = { |
| 7812 | {AttributeCommonInfo::AS_GNU, "packed" }, |
| 7813 | {AttributeCommonInfo::AS_CXX11, "gnu::packed" }, |
| 7814 | {AttributeCommonInfo::AS_C2x, "gnu::packed" }, |
| 7815 | }; |
| 7816 | struct ParsedAttrInfoPacked final : public ParsedAttrInfo { |
| 7817 | ParsedAttrInfoPacked() { |
| 7818 | AttrKind = ParsedAttr::AT_Packed; |
| 7819 | NumArgs = 0; |
| 7820 | OptArgs = 0; |
| 7821 | HasCustomParsing = 0; |
| 7822 | IsTargetSpecific = 0; |
| 7823 | IsType = 0; |
| 7824 | IsStmt = 0; |
| 7825 | IsKnownToGCC = 1; |
| 7826 | IsSupportedByPragmaAttribute = 0; |
| 7827 | Spellings = PackedSpellings; |
| 7828 | } |
| 7829 | static const ParsedAttrInfoPacked Instance; |
| 7830 | }; |
| 7831 | const ParsedAttrInfoPacked ParsedAttrInfoPacked::Instance; |
| 7832 | static constexpr ParsedAttrInfo::Spelling ParamTypestateSpellings[] = { |
| 7833 | {AttributeCommonInfo::AS_GNU, "param_typestate" }, |
| 7834 | {AttributeCommonInfo::AS_CXX11, "clang::param_typestate" }, |
| 7835 | }; |
| 7836 | struct ParsedAttrInfoParamTypestate final : public ParsedAttrInfo { |
| 7837 | ParsedAttrInfoParamTypestate() { |
| 7838 | AttrKind = ParsedAttr::AT_ParamTypestate; |
| 7839 | NumArgs = 1; |
| 7840 | OptArgs = 0; |
| 7841 | HasCustomParsing = 0; |
| 7842 | IsTargetSpecific = 0; |
| 7843 | IsType = 0; |
| 7844 | IsStmt = 0; |
| 7845 | IsKnownToGCC = 0; |
| 7846 | IsSupportedByPragmaAttribute = 1; |
| 7847 | Spellings = ParamTypestateSpellings; |
| 7848 | } |
| 7849 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7850 | if (!isa<ParmVarDecl>(D)) { |
| 7851 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 7852 | << Attr << "parameters" ; |
| 7853 | return false; |
| 7854 | } |
| 7855 | return true; |
| 7856 | } |
| 7857 | |
| 7858 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7859 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 7860 | } |
| 7861 | |
| 7862 | static const ParsedAttrInfoParamTypestate Instance; |
| 7863 | }; |
| 7864 | const ParsedAttrInfoParamTypestate ParsedAttrInfoParamTypestate::Instance; |
| 7865 | static constexpr ParsedAttrInfo::Spelling PascalSpellings[] = { |
| 7866 | {AttributeCommonInfo::AS_GNU, "pascal" }, |
| 7867 | {AttributeCommonInfo::AS_CXX11, "clang::pascal" }, |
| 7868 | {AttributeCommonInfo::AS_C2x, "clang::pascal" }, |
| 7869 | {AttributeCommonInfo::AS_Keyword, "__pascal" }, |
| 7870 | {AttributeCommonInfo::AS_Keyword, "_pascal" }, |
| 7871 | }; |
| 7872 | struct ParsedAttrInfoPascal final : public ParsedAttrInfo { |
| 7873 | ParsedAttrInfoPascal() { |
| 7874 | AttrKind = ParsedAttr::AT_Pascal; |
| 7875 | NumArgs = 0; |
| 7876 | OptArgs = 0; |
| 7877 | HasCustomParsing = 0; |
| 7878 | IsTargetSpecific = 0; |
| 7879 | IsType = 1; |
| 7880 | IsStmt = 0; |
| 7881 | IsKnownToGCC = 0; |
| 7882 | IsSupportedByPragmaAttribute = 0; |
| 7883 | Spellings = PascalSpellings; |
| 7884 | } |
| 7885 | static const ParsedAttrInfoPascal Instance; |
| 7886 | }; |
| 7887 | const ParsedAttrInfoPascal ParsedAttrInfoPascal::Instance; |
| 7888 | static constexpr ParsedAttrInfo::Spelling PassObjectSizeSpellings[] = { |
| 7889 | {AttributeCommonInfo::AS_GNU, "pass_object_size" }, |
| 7890 | {AttributeCommonInfo::AS_CXX11, "clang::pass_object_size" }, |
| 7891 | {AttributeCommonInfo::AS_C2x, "clang::pass_object_size" }, |
| 7892 | {AttributeCommonInfo::AS_GNU, "pass_dynamic_object_size" }, |
| 7893 | {AttributeCommonInfo::AS_CXX11, "clang::pass_dynamic_object_size" }, |
| 7894 | {AttributeCommonInfo::AS_C2x, "clang::pass_dynamic_object_size" }, |
| 7895 | }; |
| 7896 | struct ParsedAttrInfoPassObjectSize final : public ParsedAttrInfo { |
| 7897 | ParsedAttrInfoPassObjectSize() { |
| 7898 | AttrKind = ParsedAttr::AT_PassObjectSize; |
| 7899 | NumArgs = 1; |
| 7900 | OptArgs = 0; |
| 7901 | HasCustomParsing = 0; |
| 7902 | IsTargetSpecific = 0; |
| 7903 | IsType = 0; |
| 7904 | IsStmt = 0; |
| 7905 | IsKnownToGCC = 0; |
| 7906 | IsSupportedByPragmaAttribute = 1; |
| 7907 | Spellings = PassObjectSizeSpellings; |
| 7908 | } |
| 7909 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7910 | if (!isa<ParmVarDecl>(D)) { |
| 7911 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 7912 | << Attr << "parameters" ; |
| 7913 | return false; |
| 7914 | } |
| 7915 | return true; |
| 7916 | } |
| 7917 | |
| 7918 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 7919 | enum Spelling { |
| 7920 | GNU_pass_object_size = 0, |
| 7921 | CXX11_clang_pass_object_size = 1, |
| 7922 | C2x_clang_pass_object_size = 2, |
| 7923 | GNU_pass_dynamic_object_size = 3, |
| 7924 | CXX11_clang_pass_dynamic_object_size = 4, |
| 7925 | C2x_clang_pass_dynamic_object_size = 5, |
| 7926 | SpellingNotCalculated = 15 |
| 7927 | |
| 7928 | }; |
| 7929 | |
| 7930 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 7931 | switch (Idx) { |
| 7932 | default: llvm_unreachable("Unknown spelling list index" ); |
| 7933 | case 0: return GNU_pass_object_size; |
| 7934 | case 1: return CXX11_clang_pass_object_size; |
| 7935 | case 2: return C2x_clang_pass_object_size; |
| 7936 | case 3: return GNU_pass_dynamic_object_size; |
| 7937 | case 4: return CXX11_clang_pass_dynamic_object_size; |
| 7938 | case 5: return C2x_clang_pass_dynamic_object_size; |
| 7939 | } |
| 7940 | } |
| 7941 | |
| 7942 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7943 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 7944 | } |
| 7945 | |
| 7946 | static const ParsedAttrInfoPassObjectSize Instance; |
| 7947 | }; |
| 7948 | const ParsedAttrInfoPassObjectSize ParsedAttrInfoPassObjectSize::Instance; |
| 7949 | static constexpr ParsedAttrInfo::Spelling PatchableFunctionEntrySpellings[] = { |
| 7950 | {AttributeCommonInfo::AS_GNU, "patchable_function_entry" }, |
| 7951 | {AttributeCommonInfo::AS_CXX11, "gnu::patchable_function_entry" }, |
| 7952 | {AttributeCommonInfo::AS_C2x, "gnu::patchable_function_entry" }, |
| 7953 | }; |
| 7954 | struct ParsedAttrInfoPatchableFunctionEntry final : public ParsedAttrInfo { |
| 7955 | ParsedAttrInfoPatchableFunctionEntry() { |
| 7956 | AttrKind = ParsedAttr::AT_PatchableFunctionEntry; |
| 7957 | NumArgs = 1; |
| 7958 | OptArgs = 1; |
| 7959 | HasCustomParsing = 0; |
| 7960 | IsTargetSpecific = 1; |
| 7961 | IsType = 0; |
| 7962 | IsStmt = 0; |
| 7963 | IsKnownToGCC = 1; |
| 7964 | IsSupportedByPragmaAttribute = 1; |
| 7965 | Spellings = PatchableFunctionEntrySpellings; |
| 7966 | } |
| 7967 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 7968 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 7969 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 7970 | << Attr << "functions and Objective-C methods" ; |
| 7971 | return false; |
| 7972 | } |
| 7973 | return true; |
| 7974 | } |
| 7975 | |
| 7976 | bool existsInTarget(const TargetInfo &Target) const override { |
| 7977 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 7978 | return true && (T.getArch() == llvm::Triple::aarch64 || T.getArch() == llvm::Triple::aarch64_be || T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64); |
| 7979 | } |
| 7980 | |
| 7981 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 7982 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 7983 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 7984 | } |
| 7985 | |
| 7986 | static const ParsedAttrInfoPatchableFunctionEntry Instance; |
| 7987 | }; |
| 7988 | const ParsedAttrInfoPatchableFunctionEntry ParsedAttrInfoPatchableFunctionEntry::Instance; |
| 7989 | static constexpr ParsedAttrInfo::Spelling PcsSpellings[] = { |
| 7990 | {AttributeCommonInfo::AS_GNU, "pcs" }, |
| 7991 | {AttributeCommonInfo::AS_CXX11, "gnu::pcs" }, |
| 7992 | {AttributeCommonInfo::AS_C2x, "gnu::pcs" }, |
| 7993 | }; |
| 7994 | struct ParsedAttrInfoPcs final : public ParsedAttrInfo { |
| 7995 | ParsedAttrInfoPcs() { |
| 7996 | AttrKind = ParsedAttr::AT_Pcs; |
| 7997 | NumArgs = 1; |
| 7998 | OptArgs = 0; |
| 7999 | HasCustomParsing = 0; |
| 8000 | IsTargetSpecific = 0; |
| 8001 | IsType = 1; |
| 8002 | IsStmt = 0; |
| 8003 | IsKnownToGCC = 1; |
| 8004 | IsSupportedByPragmaAttribute = 0; |
| 8005 | Spellings = PcsSpellings; |
| 8006 | } |
| 8007 | static const ParsedAttrInfoPcs Instance; |
| 8008 | }; |
| 8009 | const ParsedAttrInfoPcs ParsedAttrInfoPcs::Instance; |
| 8010 | static constexpr ParsedAttrInfo::Spelling PointerSpellings[] = { |
| 8011 | {AttributeCommonInfo::AS_CXX11, "gsl::Pointer" }, |
| 8012 | }; |
| 8013 | struct ParsedAttrInfoPointer final : public ParsedAttrInfo { |
| 8014 | ParsedAttrInfoPointer() { |
| 8015 | AttrKind = ParsedAttr::AT_Pointer; |
| 8016 | NumArgs = 0; |
| 8017 | OptArgs = 1; |
| 8018 | HasCustomParsing = 0; |
| 8019 | IsTargetSpecific = 0; |
| 8020 | IsType = 0; |
| 8021 | IsStmt = 0; |
| 8022 | IsKnownToGCC = 0; |
| 8023 | IsSupportedByPragmaAttribute = 1; |
| 8024 | Spellings = PointerSpellings; |
| 8025 | } |
| 8026 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8027 | if (!isStruct(D)) { |
| 8028 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8029 | << Attr << "structs" ; |
| 8030 | return false; |
| 8031 | } |
| 8032 | return true; |
| 8033 | } |
| 8034 | |
| 8035 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 8036 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record_not_is_union, /*IsSupported=*/true)); |
| 8037 | } |
| 8038 | |
| 8039 | static const ParsedAttrInfoPointer Instance; |
| 8040 | }; |
| 8041 | const ParsedAttrInfoPointer ParsedAttrInfoPointer::Instance; |
| 8042 | struct ParsedAttrInfoPragmaClangBSSSection final : public ParsedAttrInfo { |
| 8043 | ParsedAttrInfoPragmaClangBSSSection() { |
| 8044 | AttrKind = ParsedAttr::AT_PragmaClangBSSSection; |
| 8045 | NumArgs = 1; |
| 8046 | OptArgs = 0; |
| 8047 | HasCustomParsing = 0; |
| 8048 | IsTargetSpecific = 0; |
| 8049 | IsType = 0; |
| 8050 | IsStmt = 0; |
| 8051 | IsKnownToGCC = 0; |
| 8052 | IsSupportedByPragmaAttribute = 0; |
| 8053 | } |
| 8054 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8055 | if (!isGlobalVar(D)) { |
| 8056 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 8057 | << Attr << "global variables" ; |
| 8058 | return false; |
| 8059 | } |
| 8060 | return true; |
| 8061 | } |
| 8062 | |
| 8063 | static const ParsedAttrInfoPragmaClangBSSSection Instance; |
| 8064 | }; |
| 8065 | const ParsedAttrInfoPragmaClangBSSSection ParsedAttrInfoPragmaClangBSSSection::Instance; |
| 8066 | struct ParsedAttrInfoPragmaClangDataSection final : public ParsedAttrInfo { |
| 8067 | ParsedAttrInfoPragmaClangDataSection() { |
| 8068 | AttrKind = ParsedAttr::AT_PragmaClangDataSection; |
| 8069 | NumArgs = 1; |
| 8070 | OptArgs = 0; |
| 8071 | HasCustomParsing = 0; |
| 8072 | IsTargetSpecific = 0; |
| 8073 | IsType = 0; |
| 8074 | IsStmt = 0; |
| 8075 | IsKnownToGCC = 0; |
| 8076 | IsSupportedByPragmaAttribute = 0; |
| 8077 | } |
| 8078 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8079 | if (!isGlobalVar(D)) { |
| 8080 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 8081 | << Attr << "global variables" ; |
| 8082 | return false; |
| 8083 | } |
| 8084 | return true; |
| 8085 | } |
| 8086 | |
| 8087 | static const ParsedAttrInfoPragmaClangDataSection Instance; |
| 8088 | }; |
| 8089 | const ParsedAttrInfoPragmaClangDataSection ParsedAttrInfoPragmaClangDataSection::Instance; |
| 8090 | struct ParsedAttrInfoPragmaClangRelroSection final : public ParsedAttrInfo { |
| 8091 | ParsedAttrInfoPragmaClangRelroSection() { |
| 8092 | AttrKind = ParsedAttr::AT_PragmaClangRelroSection; |
| 8093 | NumArgs = 1; |
| 8094 | OptArgs = 0; |
| 8095 | HasCustomParsing = 0; |
| 8096 | IsTargetSpecific = 0; |
| 8097 | IsType = 0; |
| 8098 | IsStmt = 0; |
| 8099 | IsKnownToGCC = 0; |
| 8100 | IsSupportedByPragmaAttribute = 0; |
| 8101 | } |
| 8102 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8103 | if (!isGlobalVar(D)) { |
| 8104 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 8105 | << Attr << "global variables" ; |
| 8106 | return false; |
| 8107 | } |
| 8108 | return true; |
| 8109 | } |
| 8110 | |
| 8111 | static const ParsedAttrInfoPragmaClangRelroSection Instance; |
| 8112 | }; |
| 8113 | const ParsedAttrInfoPragmaClangRelroSection ParsedAttrInfoPragmaClangRelroSection::Instance; |
| 8114 | struct ParsedAttrInfoPragmaClangRodataSection final : public ParsedAttrInfo { |
| 8115 | ParsedAttrInfoPragmaClangRodataSection() { |
| 8116 | AttrKind = ParsedAttr::AT_PragmaClangRodataSection; |
| 8117 | NumArgs = 1; |
| 8118 | OptArgs = 0; |
| 8119 | HasCustomParsing = 0; |
| 8120 | IsTargetSpecific = 0; |
| 8121 | IsType = 0; |
| 8122 | IsStmt = 0; |
| 8123 | IsKnownToGCC = 0; |
| 8124 | IsSupportedByPragmaAttribute = 0; |
| 8125 | } |
| 8126 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8127 | if (!isGlobalVar(D)) { |
| 8128 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 8129 | << Attr << "global variables" ; |
| 8130 | return false; |
| 8131 | } |
| 8132 | return true; |
| 8133 | } |
| 8134 | |
| 8135 | static const ParsedAttrInfoPragmaClangRodataSection Instance; |
| 8136 | }; |
| 8137 | const ParsedAttrInfoPragmaClangRodataSection ParsedAttrInfoPragmaClangRodataSection::Instance; |
| 8138 | struct ParsedAttrInfoPragmaClangTextSection final : public ParsedAttrInfo { |
| 8139 | ParsedAttrInfoPragmaClangTextSection() { |
| 8140 | AttrKind = ParsedAttr::AT_PragmaClangTextSection; |
| 8141 | NumArgs = 1; |
| 8142 | OptArgs = 0; |
| 8143 | HasCustomParsing = 0; |
| 8144 | IsTargetSpecific = 0; |
| 8145 | IsType = 0; |
| 8146 | IsStmt = 0; |
| 8147 | IsKnownToGCC = 0; |
| 8148 | IsSupportedByPragmaAttribute = 0; |
| 8149 | } |
| 8150 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8151 | if (!isa<FunctionDecl>(D)) { |
| 8152 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 8153 | << Attr << "functions" ; |
| 8154 | return false; |
| 8155 | } |
| 8156 | return true; |
| 8157 | } |
| 8158 | |
| 8159 | static const ParsedAttrInfoPragmaClangTextSection Instance; |
| 8160 | }; |
| 8161 | const ParsedAttrInfoPragmaClangTextSection ParsedAttrInfoPragmaClangTextSection::Instance; |
| 8162 | static constexpr ParsedAttrInfo::Spelling PreferredNameSpellings[] = { |
| 8163 | {AttributeCommonInfo::AS_GNU, "preferred_name" }, |
| 8164 | {AttributeCommonInfo::AS_CXX11, "clang::preferred_name" }, |
| 8165 | }; |
| 8166 | struct ParsedAttrInfoPreferredName final : public ParsedAttrInfo { |
| 8167 | ParsedAttrInfoPreferredName() { |
| 8168 | AttrKind = ParsedAttr::AT_PreferredName; |
| 8169 | NumArgs = 1; |
| 8170 | OptArgs = 0; |
| 8171 | HasCustomParsing = 0; |
| 8172 | IsTargetSpecific = 0; |
| 8173 | IsType = 0; |
| 8174 | IsStmt = 0; |
| 8175 | IsKnownToGCC = 0; |
| 8176 | IsSupportedByPragmaAttribute = 0; |
| 8177 | Spellings = PreferredNameSpellings; |
| 8178 | } |
| 8179 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8180 | if (!isClassTmpl(D)) { |
| 8181 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8182 | << Attr << "class templates" ; |
| 8183 | return false; |
| 8184 | } |
| 8185 | return true; |
| 8186 | } |
| 8187 | |
| 8188 | static const ParsedAttrInfoPreferredName Instance; |
| 8189 | }; |
| 8190 | const ParsedAttrInfoPreferredName ParsedAttrInfoPreferredName::Instance; |
| 8191 | static constexpr ParsedAttrInfo::Spelling PreserveAllSpellings[] = { |
| 8192 | {AttributeCommonInfo::AS_GNU, "preserve_all" }, |
| 8193 | {AttributeCommonInfo::AS_CXX11, "clang::preserve_all" }, |
| 8194 | {AttributeCommonInfo::AS_C2x, "clang::preserve_all" }, |
| 8195 | }; |
| 8196 | struct ParsedAttrInfoPreserveAll final : public ParsedAttrInfo { |
| 8197 | ParsedAttrInfoPreserveAll() { |
| 8198 | AttrKind = ParsedAttr::AT_PreserveAll; |
| 8199 | NumArgs = 0; |
| 8200 | OptArgs = 0; |
| 8201 | HasCustomParsing = 0; |
| 8202 | IsTargetSpecific = 0; |
| 8203 | IsType = 1; |
| 8204 | IsStmt = 0; |
| 8205 | IsKnownToGCC = 0; |
| 8206 | IsSupportedByPragmaAttribute = 0; |
| 8207 | Spellings = PreserveAllSpellings; |
| 8208 | } |
| 8209 | static const ParsedAttrInfoPreserveAll Instance; |
| 8210 | }; |
| 8211 | const ParsedAttrInfoPreserveAll ParsedAttrInfoPreserveAll::Instance; |
| 8212 | static constexpr ParsedAttrInfo::Spelling PreserveMostSpellings[] = { |
| 8213 | {AttributeCommonInfo::AS_GNU, "preserve_most" }, |
| 8214 | {AttributeCommonInfo::AS_CXX11, "clang::preserve_most" }, |
| 8215 | {AttributeCommonInfo::AS_C2x, "clang::preserve_most" }, |
| 8216 | }; |
| 8217 | struct ParsedAttrInfoPreserveMost final : public ParsedAttrInfo { |
| 8218 | ParsedAttrInfoPreserveMost() { |
| 8219 | AttrKind = ParsedAttr::AT_PreserveMost; |
| 8220 | NumArgs = 0; |
| 8221 | OptArgs = 0; |
| 8222 | HasCustomParsing = 0; |
| 8223 | IsTargetSpecific = 0; |
| 8224 | IsType = 1; |
| 8225 | IsStmt = 0; |
| 8226 | IsKnownToGCC = 0; |
| 8227 | IsSupportedByPragmaAttribute = 0; |
| 8228 | Spellings = PreserveMostSpellings; |
| 8229 | } |
| 8230 | static const ParsedAttrInfoPreserveMost Instance; |
| 8231 | }; |
| 8232 | const ParsedAttrInfoPreserveMost ParsedAttrInfoPreserveMost::Instance; |
| 8233 | static constexpr ParsedAttrInfo::Spelling PtGuardedBySpellings[] = { |
| 8234 | {AttributeCommonInfo::AS_GNU, "pt_guarded_by" }, |
| 8235 | }; |
| 8236 | struct ParsedAttrInfoPtGuardedBy final : public ParsedAttrInfo { |
| 8237 | ParsedAttrInfoPtGuardedBy() { |
| 8238 | AttrKind = ParsedAttr::AT_PtGuardedBy; |
| 8239 | NumArgs = 1; |
| 8240 | OptArgs = 0; |
| 8241 | HasCustomParsing = 0; |
| 8242 | IsTargetSpecific = 0; |
| 8243 | IsType = 0; |
| 8244 | IsStmt = 0; |
| 8245 | IsKnownToGCC = 0; |
| 8246 | IsSupportedByPragmaAttribute = 0; |
| 8247 | Spellings = PtGuardedBySpellings; |
| 8248 | } |
| 8249 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8250 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
| 8251 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8252 | << Attr << "non-static data members and global variables" ; |
| 8253 | return false; |
| 8254 | } |
| 8255 | return true; |
| 8256 | } |
| 8257 | |
| 8258 | static const ParsedAttrInfoPtGuardedBy Instance; |
| 8259 | }; |
| 8260 | const ParsedAttrInfoPtGuardedBy ParsedAttrInfoPtGuardedBy::Instance; |
| 8261 | static constexpr ParsedAttrInfo::Spelling PtGuardedVarSpellings[] = { |
| 8262 | {AttributeCommonInfo::AS_GNU, "pt_guarded_var" }, |
| 8263 | {AttributeCommonInfo::AS_CXX11, "clang::pt_guarded_var" }, |
| 8264 | }; |
| 8265 | struct ParsedAttrInfoPtGuardedVar final : public ParsedAttrInfo { |
| 8266 | ParsedAttrInfoPtGuardedVar() { |
| 8267 | AttrKind = ParsedAttr::AT_PtGuardedVar; |
| 8268 | NumArgs = 0; |
| 8269 | OptArgs = 0; |
| 8270 | HasCustomParsing = 0; |
| 8271 | IsTargetSpecific = 0; |
| 8272 | IsType = 0; |
| 8273 | IsStmt = 0; |
| 8274 | IsKnownToGCC = 0; |
| 8275 | IsSupportedByPragmaAttribute = 0; |
| 8276 | Spellings = PtGuardedVarSpellings; |
| 8277 | } |
| 8278 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8279 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
| 8280 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8281 | << Attr << "non-static data members and global variables" ; |
| 8282 | return false; |
| 8283 | } |
| 8284 | return true; |
| 8285 | } |
| 8286 | |
| 8287 | static const ParsedAttrInfoPtGuardedVar Instance; |
| 8288 | }; |
| 8289 | const ParsedAttrInfoPtGuardedVar ParsedAttrInfoPtGuardedVar::Instance; |
| 8290 | static constexpr ParsedAttrInfo::Spelling Ptr32Spellings[] = { |
| 8291 | {AttributeCommonInfo::AS_Keyword, "__ptr32" }, |
| 8292 | }; |
| 8293 | struct ParsedAttrInfoPtr32 final : public ParsedAttrInfo { |
| 8294 | ParsedAttrInfoPtr32() { |
| 8295 | AttrKind = ParsedAttr::AT_Ptr32; |
| 8296 | NumArgs = 0; |
| 8297 | OptArgs = 0; |
| 8298 | HasCustomParsing = 0; |
| 8299 | IsTargetSpecific = 0; |
| 8300 | IsType = 1; |
| 8301 | IsStmt = 0; |
| 8302 | IsKnownToGCC = 0; |
| 8303 | IsSupportedByPragmaAttribute = 0; |
| 8304 | Spellings = Ptr32Spellings; |
| 8305 | } |
| 8306 | static const ParsedAttrInfoPtr32 Instance; |
| 8307 | }; |
| 8308 | const ParsedAttrInfoPtr32 ParsedAttrInfoPtr32::Instance; |
| 8309 | static constexpr ParsedAttrInfo::Spelling Ptr64Spellings[] = { |
| 8310 | {AttributeCommonInfo::AS_Keyword, "__ptr64" }, |
| 8311 | }; |
| 8312 | struct ParsedAttrInfoPtr64 final : public ParsedAttrInfo { |
| 8313 | ParsedAttrInfoPtr64() { |
| 8314 | AttrKind = ParsedAttr::AT_Ptr64; |
| 8315 | NumArgs = 0; |
| 8316 | OptArgs = 0; |
| 8317 | HasCustomParsing = 0; |
| 8318 | IsTargetSpecific = 0; |
| 8319 | IsType = 1; |
| 8320 | IsStmt = 0; |
| 8321 | IsKnownToGCC = 0; |
| 8322 | IsSupportedByPragmaAttribute = 0; |
| 8323 | Spellings = Ptr64Spellings; |
| 8324 | } |
| 8325 | static const ParsedAttrInfoPtr64 Instance; |
| 8326 | }; |
| 8327 | const ParsedAttrInfoPtr64 ParsedAttrInfoPtr64::Instance; |
| 8328 | static constexpr ParsedAttrInfo::Spelling PureSpellings[] = { |
| 8329 | {AttributeCommonInfo::AS_GNU, "pure" }, |
| 8330 | {AttributeCommonInfo::AS_CXX11, "gnu::pure" }, |
| 8331 | {AttributeCommonInfo::AS_C2x, "gnu::pure" }, |
| 8332 | }; |
| 8333 | struct ParsedAttrInfoPure final : public ParsedAttrInfo { |
| 8334 | ParsedAttrInfoPure() { |
| 8335 | AttrKind = ParsedAttr::AT_Pure; |
| 8336 | NumArgs = 0; |
| 8337 | OptArgs = 0; |
| 8338 | HasCustomParsing = 0; |
| 8339 | IsTargetSpecific = 0; |
| 8340 | IsType = 0; |
| 8341 | IsStmt = 0; |
| 8342 | IsKnownToGCC = 1; |
| 8343 | IsSupportedByPragmaAttribute = 0; |
| 8344 | Spellings = PureSpellings; |
| 8345 | } |
| 8346 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 8347 | D->addAttr(::new (S.Context) PureAttr(S.Context, Attr)); |
| 8348 | return AttributeApplied; |
| 8349 | } |
| 8350 | |
| 8351 | static const ParsedAttrInfoPure Instance; |
| 8352 | }; |
| 8353 | const ParsedAttrInfoPure ParsedAttrInfoPure::Instance; |
| 8354 | static constexpr ParsedAttrInfo::Spelling RegCallSpellings[] = { |
| 8355 | {AttributeCommonInfo::AS_GNU, "regcall" }, |
| 8356 | {AttributeCommonInfo::AS_CXX11, "gnu::regcall" }, |
| 8357 | {AttributeCommonInfo::AS_C2x, "gnu::regcall" }, |
| 8358 | {AttributeCommonInfo::AS_Keyword, "__regcall" }, |
| 8359 | }; |
| 8360 | struct ParsedAttrInfoRegCall final : public ParsedAttrInfo { |
| 8361 | ParsedAttrInfoRegCall() { |
| 8362 | AttrKind = ParsedAttr::AT_RegCall; |
| 8363 | NumArgs = 0; |
| 8364 | OptArgs = 0; |
| 8365 | HasCustomParsing = 0; |
| 8366 | IsTargetSpecific = 0; |
| 8367 | IsType = 1; |
| 8368 | IsStmt = 0; |
| 8369 | IsKnownToGCC = 1; |
| 8370 | IsSupportedByPragmaAttribute = 0; |
| 8371 | Spellings = RegCallSpellings; |
| 8372 | } |
| 8373 | static const ParsedAttrInfoRegCall Instance; |
| 8374 | }; |
| 8375 | const ParsedAttrInfoRegCall ParsedAttrInfoRegCall::Instance; |
| 8376 | static constexpr ParsedAttrInfo::Spelling RegparmSpellings[] = { |
| 8377 | {AttributeCommonInfo::AS_GNU, "regparm" }, |
| 8378 | {AttributeCommonInfo::AS_CXX11, "gnu::regparm" }, |
| 8379 | {AttributeCommonInfo::AS_C2x, "gnu::regparm" }, |
| 8380 | }; |
| 8381 | struct ParsedAttrInfoRegparm final : public ParsedAttrInfo { |
| 8382 | ParsedAttrInfoRegparm() { |
| 8383 | AttrKind = ParsedAttr::AT_Regparm; |
| 8384 | NumArgs = 1; |
| 8385 | OptArgs = 0; |
| 8386 | HasCustomParsing = 0; |
| 8387 | IsTargetSpecific = 0; |
| 8388 | IsType = 1; |
| 8389 | IsStmt = 0; |
| 8390 | IsKnownToGCC = 1; |
| 8391 | IsSupportedByPragmaAttribute = 0; |
| 8392 | Spellings = RegparmSpellings; |
| 8393 | } |
| 8394 | static const ParsedAttrInfoRegparm Instance; |
| 8395 | }; |
| 8396 | const ParsedAttrInfoRegparm ParsedAttrInfoRegparm::Instance; |
| 8397 | static constexpr ParsedAttrInfo::Spelling ReinitializesSpellings[] = { |
| 8398 | {AttributeCommonInfo::AS_GNU, "reinitializes" }, |
| 8399 | {AttributeCommonInfo::AS_CXX11, "clang::reinitializes" }, |
| 8400 | }; |
| 8401 | struct ParsedAttrInfoReinitializes final : public ParsedAttrInfo { |
| 8402 | ParsedAttrInfoReinitializes() { |
| 8403 | AttrKind = ParsedAttr::AT_Reinitializes; |
| 8404 | NumArgs = 0; |
| 8405 | OptArgs = 0; |
| 8406 | HasCustomParsing = 0; |
| 8407 | IsTargetSpecific = 0; |
| 8408 | IsType = 0; |
| 8409 | IsStmt = 0; |
| 8410 | IsKnownToGCC = 0; |
| 8411 | IsSupportedByPragmaAttribute = 0; |
| 8412 | Spellings = ReinitializesSpellings; |
| 8413 | } |
| 8414 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8415 | if (!isNonStaticNonConstCXXMethod(D)) { |
| 8416 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 8417 | << Attr << "non-static non-const member functions" ; |
| 8418 | return false; |
| 8419 | } |
| 8420 | return true; |
| 8421 | } |
| 8422 | |
| 8423 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 8424 | D->addAttr(::new (S.Context) ReinitializesAttr(S.Context, Attr)); |
| 8425 | return AttributeApplied; |
| 8426 | } |
| 8427 | |
| 8428 | static const ParsedAttrInfoReinitializes Instance; |
| 8429 | }; |
| 8430 | const ParsedAttrInfoReinitializes ParsedAttrInfoReinitializes::Instance; |
| 8431 | static constexpr ParsedAttrInfo::Spelling ReleaseCapabilitySpellings[] = { |
| 8432 | {AttributeCommonInfo::AS_GNU, "release_capability" }, |
| 8433 | {AttributeCommonInfo::AS_CXX11, "clang::release_capability" }, |
| 8434 | {AttributeCommonInfo::AS_GNU, "release_shared_capability" }, |
| 8435 | {AttributeCommonInfo::AS_CXX11, "clang::release_shared_capability" }, |
| 8436 | {AttributeCommonInfo::AS_GNU, "release_generic_capability" }, |
| 8437 | {AttributeCommonInfo::AS_CXX11, "clang::release_generic_capability" }, |
| 8438 | {AttributeCommonInfo::AS_GNU, "unlock_function" }, |
| 8439 | {AttributeCommonInfo::AS_CXX11, "clang::unlock_function" }, |
| 8440 | }; |
| 8441 | struct ParsedAttrInfoReleaseCapability final : public ParsedAttrInfo { |
| 8442 | ParsedAttrInfoReleaseCapability() { |
| 8443 | AttrKind = ParsedAttr::AT_ReleaseCapability; |
| 8444 | NumArgs = 0; |
| 8445 | OptArgs = 15; |
| 8446 | HasCustomParsing = 0; |
| 8447 | IsTargetSpecific = 0; |
| 8448 | IsType = 0; |
| 8449 | IsStmt = 0; |
| 8450 | IsKnownToGCC = 0; |
| 8451 | IsSupportedByPragmaAttribute = 0; |
| 8452 | Spellings = ReleaseCapabilitySpellings; |
| 8453 | } |
| 8454 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8455 | if (!isa<FunctionDecl>(D)) { |
| 8456 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8457 | << Attr << "functions" ; |
| 8458 | return false; |
| 8459 | } |
| 8460 | return true; |
| 8461 | } |
| 8462 | |
| 8463 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 8464 | enum Spelling { |
| 8465 | GNU_release_capability = 0, |
| 8466 | CXX11_clang_release_capability = 1, |
| 8467 | GNU_release_shared_capability = 2, |
| 8468 | CXX11_clang_release_shared_capability = 3, |
| 8469 | GNU_release_generic_capability = 4, |
| 8470 | CXX11_clang_release_generic_capability = 5, |
| 8471 | GNU_unlock_function = 6, |
| 8472 | CXX11_clang_unlock_function = 7, |
| 8473 | SpellingNotCalculated = 15 |
| 8474 | |
| 8475 | }; |
| 8476 | |
| 8477 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 8478 | switch (Idx) { |
| 8479 | default: llvm_unreachable("Unknown spelling list index" ); |
| 8480 | case 0: return GNU_release_capability; |
| 8481 | case 1: return CXX11_clang_release_capability; |
| 8482 | case 2: return GNU_release_shared_capability; |
| 8483 | case 3: return CXX11_clang_release_shared_capability; |
| 8484 | case 4: return GNU_release_generic_capability; |
| 8485 | case 5: return CXX11_clang_release_generic_capability; |
| 8486 | case 6: return GNU_unlock_function; |
| 8487 | case 7: return CXX11_clang_unlock_function; |
| 8488 | } |
| 8489 | } |
| 8490 | |
| 8491 | static const ParsedAttrInfoReleaseCapability Instance; |
| 8492 | }; |
| 8493 | const ParsedAttrInfoReleaseCapability ParsedAttrInfoReleaseCapability::Instance; |
| 8494 | static constexpr ParsedAttrInfo::Spelling ReleaseHandleSpellings[] = { |
| 8495 | {AttributeCommonInfo::AS_GNU, "release_handle" }, |
| 8496 | {AttributeCommonInfo::AS_CXX11, "clang::release_handle" }, |
| 8497 | {AttributeCommonInfo::AS_C2x, "clang::release_handle" }, |
| 8498 | }; |
| 8499 | struct ParsedAttrInfoReleaseHandle final : public ParsedAttrInfo { |
| 8500 | ParsedAttrInfoReleaseHandle() { |
| 8501 | AttrKind = ParsedAttr::AT_ReleaseHandle; |
| 8502 | NumArgs = 1; |
| 8503 | OptArgs = 0; |
| 8504 | HasCustomParsing = 0; |
| 8505 | IsTargetSpecific = 0; |
| 8506 | IsType = 0; |
| 8507 | IsStmt = 0; |
| 8508 | IsKnownToGCC = 0; |
| 8509 | IsSupportedByPragmaAttribute = 1; |
| 8510 | Spellings = ReleaseHandleSpellings; |
| 8511 | } |
| 8512 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8513 | if (!isa<ParmVarDecl>(D)) { |
| 8514 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8515 | << Attr << "parameters" ; |
| 8516 | return false; |
| 8517 | } |
| 8518 | return true; |
| 8519 | } |
| 8520 | |
| 8521 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 8522 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 8523 | } |
| 8524 | |
| 8525 | static const ParsedAttrInfoReleaseHandle Instance; |
| 8526 | }; |
| 8527 | const ParsedAttrInfoReleaseHandle ParsedAttrInfoReleaseHandle::Instance; |
| 8528 | static constexpr ParsedAttrInfo::Spelling RenderScriptKernelSpellings[] = { |
| 8529 | {AttributeCommonInfo::AS_GNU, "kernel" }, |
| 8530 | }; |
| 8531 | struct ParsedAttrInfoRenderScriptKernel final : public ParsedAttrInfo { |
| 8532 | ParsedAttrInfoRenderScriptKernel() { |
| 8533 | AttrKind = ParsedAttr::AT_RenderScriptKernel; |
| 8534 | NumArgs = 0; |
| 8535 | OptArgs = 0; |
| 8536 | HasCustomParsing = 0; |
| 8537 | IsTargetSpecific = 0; |
| 8538 | IsType = 0; |
| 8539 | IsStmt = 0; |
| 8540 | IsKnownToGCC = 0; |
| 8541 | IsSupportedByPragmaAttribute = 1; |
| 8542 | Spellings = RenderScriptKernelSpellings; |
| 8543 | } |
| 8544 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8545 | if (!isa<FunctionDecl>(D)) { |
| 8546 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8547 | << Attr << "functions" ; |
| 8548 | return false; |
| 8549 | } |
| 8550 | return true; |
| 8551 | } |
| 8552 | |
| 8553 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 8554 | auto &LangOpts = S.LangOpts; |
| 8555 | if (LangOpts.RenderScript) |
| 8556 | return true; |
| 8557 | |
| 8558 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 8559 | return false; |
| 8560 | } |
| 8561 | |
| 8562 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 8563 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 8564 | } |
| 8565 | |
| 8566 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 8567 | D->addAttr(::new (S.Context) RenderScriptKernelAttr(S.Context, Attr)); |
| 8568 | return AttributeApplied; |
| 8569 | } |
| 8570 | |
| 8571 | static const ParsedAttrInfoRenderScriptKernel Instance; |
| 8572 | }; |
| 8573 | const ParsedAttrInfoRenderScriptKernel ParsedAttrInfoRenderScriptKernel::Instance; |
| 8574 | static constexpr ParsedAttrInfo::Spelling ReqdWorkGroupSizeSpellings[] = { |
| 8575 | {AttributeCommonInfo::AS_GNU, "reqd_work_group_size" }, |
| 8576 | }; |
| 8577 | struct ParsedAttrInfoReqdWorkGroupSize final : public ParsedAttrInfo { |
| 8578 | ParsedAttrInfoReqdWorkGroupSize() { |
| 8579 | AttrKind = ParsedAttr::AT_ReqdWorkGroupSize; |
| 8580 | NumArgs = 3; |
| 8581 | OptArgs = 0; |
| 8582 | HasCustomParsing = 0; |
| 8583 | IsTargetSpecific = 0; |
| 8584 | IsType = 0; |
| 8585 | IsStmt = 0; |
| 8586 | IsKnownToGCC = 0; |
| 8587 | IsSupportedByPragmaAttribute = 1; |
| 8588 | Spellings = ReqdWorkGroupSizeSpellings; |
| 8589 | } |
| 8590 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8591 | if (!isa<FunctionDecl>(D)) { |
| 8592 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 8593 | << Attr << "functions" ; |
| 8594 | return false; |
| 8595 | } |
| 8596 | return true; |
| 8597 | } |
| 8598 | |
| 8599 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 8600 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 8601 | } |
| 8602 | |
| 8603 | static const ParsedAttrInfoReqdWorkGroupSize Instance; |
| 8604 | }; |
| 8605 | const ParsedAttrInfoReqdWorkGroupSize ParsedAttrInfoReqdWorkGroupSize::Instance; |
| 8606 | static constexpr ParsedAttrInfo::Spelling RequiresCapabilitySpellings[] = { |
| 8607 | {AttributeCommonInfo::AS_GNU, "requires_capability" }, |
| 8608 | {AttributeCommonInfo::AS_CXX11, "clang::requires_capability" }, |
| 8609 | {AttributeCommonInfo::AS_GNU, "exclusive_locks_required" }, |
| 8610 | {AttributeCommonInfo::AS_CXX11, "clang::exclusive_locks_required" }, |
| 8611 | {AttributeCommonInfo::AS_GNU, "requires_shared_capability" }, |
| 8612 | {AttributeCommonInfo::AS_CXX11, "clang::requires_shared_capability" }, |
| 8613 | {AttributeCommonInfo::AS_GNU, "shared_locks_required" }, |
| 8614 | {AttributeCommonInfo::AS_CXX11, "clang::shared_locks_required" }, |
| 8615 | }; |
| 8616 | struct ParsedAttrInfoRequiresCapability final : public ParsedAttrInfo { |
| 8617 | ParsedAttrInfoRequiresCapability() { |
| 8618 | AttrKind = ParsedAttr::AT_RequiresCapability; |
| 8619 | NumArgs = 0; |
| 8620 | OptArgs = 15; |
| 8621 | HasCustomParsing = 0; |
| 8622 | IsTargetSpecific = 0; |
| 8623 | IsType = 0; |
| 8624 | IsStmt = 0; |
| 8625 | IsKnownToGCC = 0; |
| 8626 | IsSupportedByPragmaAttribute = 0; |
| 8627 | Spellings = RequiresCapabilitySpellings; |
| 8628 | } |
| 8629 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8630 | if (!isa<FunctionDecl>(D)) { |
| 8631 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8632 | << Attr << "functions" ; |
| 8633 | return false; |
| 8634 | } |
| 8635 | return true; |
| 8636 | } |
| 8637 | |
| 8638 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 8639 | enum Spelling { |
| 8640 | GNU_requires_capability = 0, |
| 8641 | CXX11_clang_requires_capability = 1, |
| 8642 | GNU_exclusive_locks_required = 2, |
| 8643 | CXX11_clang_exclusive_locks_required = 3, |
| 8644 | GNU_requires_shared_capability = 4, |
| 8645 | CXX11_clang_requires_shared_capability = 5, |
| 8646 | GNU_shared_locks_required = 6, |
| 8647 | CXX11_clang_shared_locks_required = 7, |
| 8648 | SpellingNotCalculated = 15 |
| 8649 | |
| 8650 | }; |
| 8651 | |
| 8652 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 8653 | switch (Idx) { |
| 8654 | default: llvm_unreachable("Unknown spelling list index" ); |
| 8655 | case 0: return GNU_requires_capability; |
| 8656 | case 1: return CXX11_clang_requires_capability; |
| 8657 | case 2: return GNU_exclusive_locks_required; |
| 8658 | case 3: return CXX11_clang_exclusive_locks_required; |
| 8659 | case 4: return GNU_requires_shared_capability; |
| 8660 | case 5: return CXX11_clang_requires_shared_capability; |
| 8661 | case 6: return GNU_shared_locks_required; |
| 8662 | case 7: return CXX11_clang_shared_locks_required; |
| 8663 | } |
| 8664 | } |
| 8665 | |
| 8666 | static const ParsedAttrInfoRequiresCapability Instance; |
| 8667 | }; |
| 8668 | const ParsedAttrInfoRequiresCapability ParsedAttrInfoRequiresCapability::Instance; |
| 8669 | static constexpr ParsedAttrInfo::Spelling RestrictSpellings[] = { |
| 8670 | {AttributeCommonInfo::AS_Declspec, "restrict" }, |
| 8671 | {AttributeCommonInfo::AS_GNU, "malloc" }, |
| 8672 | {AttributeCommonInfo::AS_CXX11, "gnu::malloc" }, |
| 8673 | {AttributeCommonInfo::AS_C2x, "gnu::malloc" }, |
| 8674 | }; |
| 8675 | struct ParsedAttrInfoRestrict final : public ParsedAttrInfo { |
| 8676 | ParsedAttrInfoRestrict() { |
| 8677 | AttrKind = ParsedAttr::AT_Restrict; |
| 8678 | NumArgs = 0; |
| 8679 | OptArgs = 0; |
| 8680 | HasCustomParsing = 0; |
| 8681 | IsTargetSpecific = 0; |
| 8682 | IsType = 0; |
| 8683 | IsStmt = 0; |
| 8684 | IsKnownToGCC = 1; |
| 8685 | IsSupportedByPragmaAttribute = 1; |
| 8686 | Spellings = RestrictSpellings; |
| 8687 | } |
| 8688 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8689 | if (!isa<FunctionDecl>(D)) { |
| 8690 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8691 | << Attr << "functions" ; |
| 8692 | return false; |
| 8693 | } |
| 8694 | return true; |
| 8695 | } |
| 8696 | |
| 8697 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 8698 | enum Spelling { |
| 8699 | Declspec_restrict = 0, |
| 8700 | GNU_malloc = 1, |
| 8701 | CXX11_gnu_malloc = 2, |
| 8702 | C2x_gnu_malloc = 3, |
| 8703 | SpellingNotCalculated = 15 |
| 8704 | |
| 8705 | }; |
| 8706 | |
| 8707 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 8708 | switch (Idx) { |
| 8709 | default: llvm_unreachable("Unknown spelling list index" ); |
| 8710 | case 0: return Declspec_restrict; |
| 8711 | case 1: return GNU_malloc; |
| 8712 | case 2: return CXX11_gnu_malloc; |
| 8713 | case 3: return C2x_gnu_malloc; |
| 8714 | } |
| 8715 | } |
| 8716 | |
| 8717 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 8718 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 8719 | } |
| 8720 | |
| 8721 | static const ParsedAttrInfoRestrict Instance; |
| 8722 | }; |
| 8723 | const ParsedAttrInfoRestrict ParsedAttrInfoRestrict::Instance; |
| 8724 | static constexpr ParsedAttrInfo::Spelling ReturnTypestateSpellings[] = { |
| 8725 | {AttributeCommonInfo::AS_GNU, "return_typestate" }, |
| 8726 | {AttributeCommonInfo::AS_CXX11, "clang::return_typestate" }, |
| 8727 | }; |
| 8728 | struct ParsedAttrInfoReturnTypestate final : public ParsedAttrInfo { |
| 8729 | ParsedAttrInfoReturnTypestate() { |
| 8730 | AttrKind = ParsedAttr::AT_ReturnTypestate; |
| 8731 | NumArgs = 1; |
| 8732 | OptArgs = 0; |
| 8733 | HasCustomParsing = 0; |
| 8734 | IsTargetSpecific = 0; |
| 8735 | IsType = 0; |
| 8736 | IsStmt = 0; |
| 8737 | IsKnownToGCC = 0; |
| 8738 | IsSupportedByPragmaAttribute = 1; |
| 8739 | Spellings = ReturnTypestateSpellings; |
| 8740 | } |
| 8741 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8742 | if (!isa<FunctionDecl>(D) && !isa<ParmVarDecl>(D)) { |
| 8743 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8744 | << Attr << "functions and parameters" ; |
| 8745 | return false; |
| 8746 | } |
| 8747 | return true; |
| 8748 | } |
| 8749 | |
| 8750 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 8751 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 8752 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 8753 | } |
| 8754 | |
| 8755 | static const ParsedAttrInfoReturnTypestate Instance; |
| 8756 | }; |
| 8757 | const ParsedAttrInfoReturnTypestate ParsedAttrInfoReturnTypestate::Instance; |
| 8758 | static constexpr ParsedAttrInfo::Spelling ReturnsNonNullSpellings[] = { |
| 8759 | {AttributeCommonInfo::AS_GNU, "returns_nonnull" }, |
| 8760 | {AttributeCommonInfo::AS_CXX11, "gnu::returns_nonnull" }, |
| 8761 | {AttributeCommonInfo::AS_C2x, "gnu::returns_nonnull" }, |
| 8762 | }; |
| 8763 | struct ParsedAttrInfoReturnsNonNull final : public ParsedAttrInfo { |
| 8764 | ParsedAttrInfoReturnsNonNull() { |
| 8765 | AttrKind = ParsedAttr::AT_ReturnsNonNull; |
| 8766 | NumArgs = 0; |
| 8767 | OptArgs = 0; |
| 8768 | HasCustomParsing = 0; |
| 8769 | IsTargetSpecific = 0; |
| 8770 | IsType = 0; |
| 8771 | IsStmt = 0; |
| 8772 | IsKnownToGCC = 1; |
| 8773 | IsSupportedByPragmaAttribute = 1; |
| 8774 | Spellings = ReturnsNonNullSpellings; |
| 8775 | } |
| 8776 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8777 | if (!isa<ObjCMethodDecl>(D) && !isa<FunctionDecl>(D)) { |
| 8778 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8779 | << Attr << "Objective-C methods and functions" ; |
| 8780 | return false; |
| 8781 | } |
| 8782 | return true; |
| 8783 | } |
| 8784 | |
| 8785 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 8786 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 8787 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 8788 | } |
| 8789 | |
| 8790 | static const ParsedAttrInfoReturnsNonNull Instance; |
| 8791 | }; |
| 8792 | const ParsedAttrInfoReturnsNonNull ParsedAttrInfoReturnsNonNull::Instance; |
| 8793 | static constexpr ParsedAttrInfo::Spelling ReturnsTwiceSpellings[] = { |
| 8794 | {AttributeCommonInfo::AS_GNU, "returns_twice" }, |
| 8795 | {AttributeCommonInfo::AS_CXX11, "gnu::returns_twice" }, |
| 8796 | {AttributeCommonInfo::AS_C2x, "gnu::returns_twice" }, |
| 8797 | }; |
| 8798 | struct ParsedAttrInfoReturnsTwice final : public ParsedAttrInfo { |
| 8799 | ParsedAttrInfoReturnsTwice() { |
| 8800 | AttrKind = ParsedAttr::AT_ReturnsTwice; |
| 8801 | NumArgs = 0; |
| 8802 | OptArgs = 0; |
| 8803 | HasCustomParsing = 0; |
| 8804 | IsTargetSpecific = 0; |
| 8805 | IsType = 0; |
| 8806 | IsStmt = 0; |
| 8807 | IsKnownToGCC = 1; |
| 8808 | IsSupportedByPragmaAttribute = 1; |
| 8809 | Spellings = ReturnsTwiceSpellings; |
| 8810 | } |
| 8811 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8812 | if (!isa<FunctionDecl>(D)) { |
| 8813 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8814 | << Attr << "functions" ; |
| 8815 | return false; |
| 8816 | } |
| 8817 | return true; |
| 8818 | } |
| 8819 | |
| 8820 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 8821 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 8822 | } |
| 8823 | |
| 8824 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 8825 | D->addAttr(::new (S.Context) ReturnsTwiceAttr(S.Context, Attr)); |
| 8826 | return AttributeApplied; |
| 8827 | } |
| 8828 | |
| 8829 | static const ParsedAttrInfoReturnsTwice Instance; |
| 8830 | }; |
| 8831 | const ParsedAttrInfoReturnsTwice ParsedAttrInfoReturnsTwice::Instance; |
| 8832 | static constexpr ParsedAttrInfo::Spelling SPtrSpellings[] = { |
| 8833 | {AttributeCommonInfo::AS_Keyword, "__sptr" }, |
| 8834 | }; |
| 8835 | struct ParsedAttrInfoSPtr final : public ParsedAttrInfo { |
| 8836 | ParsedAttrInfoSPtr() { |
| 8837 | AttrKind = ParsedAttr::AT_SPtr; |
| 8838 | NumArgs = 0; |
| 8839 | OptArgs = 0; |
| 8840 | HasCustomParsing = 0; |
| 8841 | IsTargetSpecific = 0; |
| 8842 | IsType = 1; |
| 8843 | IsStmt = 0; |
| 8844 | IsKnownToGCC = 0; |
| 8845 | IsSupportedByPragmaAttribute = 0; |
| 8846 | Spellings = SPtrSpellings; |
| 8847 | } |
| 8848 | static const ParsedAttrInfoSPtr Instance; |
| 8849 | }; |
| 8850 | const ParsedAttrInfoSPtr ParsedAttrInfoSPtr::Instance; |
| 8851 | static constexpr ParsedAttrInfo::Spelling SYCLKernelSpellings[] = { |
| 8852 | {AttributeCommonInfo::AS_GNU, "sycl_kernel" }, |
| 8853 | {AttributeCommonInfo::AS_CXX11, "clang::sycl_kernel" }, |
| 8854 | {AttributeCommonInfo::AS_C2x, "clang::sycl_kernel" }, |
| 8855 | }; |
| 8856 | struct ParsedAttrInfoSYCLKernel final : public ParsedAttrInfo { |
| 8857 | ParsedAttrInfoSYCLKernel() { |
| 8858 | AttrKind = ParsedAttr::AT_SYCLKernel; |
| 8859 | NumArgs = 0; |
| 8860 | OptArgs = 0; |
| 8861 | HasCustomParsing = 0; |
| 8862 | IsTargetSpecific = 0; |
| 8863 | IsType = 0; |
| 8864 | IsStmt = 0; |
| 8865 | IsKnownToGCC = 0; |
| 8866 | IsSupportedByPragmaAttribute = 0; |
| 8867 | Spellings = SYCLKernelSpellings; |
| 8868 | } |
| 8869 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8870 | if (!isFunctionTmpl(D)) { |
| 8871 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8872 | << Attr << "function templates" ; |
| 8873 | return false; |
| 8874 | } |
| 8875 | return true; |
| 8876 | } |
| 8877 | |
| 8878 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 8879 | auto &LangOpts = S.LangOpts; |
| 8880 | if (LangOpts.SYCLIsDevice) |
| 8881 | return true; |
| 8882 | |
| 8883 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 8884 | return false; |
| 8885 | } |
| 8886 | |
| 8887 | static const ParsedAttrInfoSYCLKernel Instance; |
| 8888 | }; |
| 8889 | const ParsedAttrInfoSYCLKernel ParsedAttrInfoSYCLKernel::Instance; |
| 8890 | static constexpr ParsedAttrInfo::Spelling ScopedLockableSpellings[] = { |
| 8891 | {AttributeCommonInfo::AS_GNU, "scoped_lockable" }, |
| 8892 | {AttributeCommonInfo::AS_CXX11, "clang::scoped_lockable" }, |
| 8893 | }; |
| 8894 | struct ParsedAttrInfoScopedLockable final : public ParsedAttrInfo { |
| 8895 | ParsedAttrInfoScopedLockable() { |
| 8896 | AttrKind = ParsedAttr::AT_ScopedLockable; |
| 8897 | NumArgs = 0; |
| 8898 | OptArgs = 0; |
| 8899 | HasCustomParsing = 0; |
| 8900 | IsTargetSpecific = 0; |
| 8901 | IsType = 0; |
| 8902 | IsStmt = 0; |
| 8903 | IsKnownToGCC = 0; |
| 8904 | IsSupportedByPragmaAttribute = 1; |
| 8905 | Spellings = ScopedLockableSpellings; |
| 8906 | } |
| 8907 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8908 | if (!isa<RecordDecl>(D)) { |
| 8909 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 8910 | << Attr << "structs, unions, and classes" ; |
| 8911 | return false; |
| 8912 | } |
| 8913 | return true; |
| 8914 | } |
| 8915 | |
| 8916 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 8917 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 8918 | } |
| 8919 | |
| 8920 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 8921 | D->addAttr(::new (S.Context) ScopedLockableAttr(S.Context, Attr)); |
| 8922 | return AttributeApplied; |
| 8923 | } |
| 8924 | |
| 8925 | static const ParsedAttrInfoScopedLockable Instance; |
| 8926 | }; |
| 8927 | const ParsedAttrInfoScopedLockable ParsedAttrInfoScopedLockable::Instance; |
| 8928 | static constexpr ParsedAttrInfo::Spelling SectionSpellings[] = { |
| 8929 | {AttributeCommonInfo::AS_GNU, "section" }, |
| 8930 | {AttributeCommonInfo::AS_CXX11, "gnu::section" }, |
| 8931 | {AttributeCommonInfo::AS_C2x, "gnu::section" }, |
| 8932 | {AttributeCommonInfo::AS_Declspec, "allocate" }, |
| 8933 | }; |
| 8934 | struct ParsedAttrInfoSection final : public ParsedAttrInfo { |
| 8935 | ParsedAttrInfoSection() { |
| 8936 | AttrKind = ParsedAttr::AT_Section; |
| 8937 | NumArgs = 1; |
| 8938 | OptArgs = 0; |
| 8939 | HasCustomParsing = 0; |
| 8940 | IsTargetSpecific = 0; |
| 8941 | IsType = 0; |
| 8942 | IsStmt = 0; |
| 8943 | IsKnownToGCC = 1; |
| 8944 | IsSupportedByPragmaAttribute = 1; |
| 8945 | Spellings = SectionSpellings; |
| 8946 | } |
| 8947 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 8948 | if (!isa<FunctionDecl>(D) && !isGlobalVar(D) && !isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D)) { |
| 8949 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 8950 | << Attr << "functions, global variables, Objective-C methods, and Objective-C properties" ; |
| 8951 | return false; |
| 8952 | } |
| 8953 | return true; |
| 8954 | } |
| 8955 | |
| 8956 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 8957 | enum Spelling { |
| 8958 | GNU_section = 0, |
| 8959 | CXX11_gnu_section = 1, |
| 8960 | C2x_gnu_section = 2, |
| 8961 | Declspec_allocate = 3, |
| 8962 | SpellingNotCalculated = 15 |
| 8963 | |
| 8964 | }; |
| 8965 | |
| 8966 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 8967 | switch (Idx) { |
| 8968 | default: llvm_unreachable("Unknown spelling list index" ); |
| 8969 | case 0: return GNU_section; |
| 8970 | case 1: return CXX11_gnu_section; |
| 8971 | case 2: return C2x_gnu_section; |
| 8972 | case 3: return Declspec_allocate; |
| 8973 | } |
| 8974 | } |
| 8975 | |
| 8976 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 8977 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 8978 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
| 8979 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 8980 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
| 8981 | } |
| 8982 | |
| 8983 | static const ParsedAttrInfoSection Instance; |
| 8984 | }; |
| 8985 | const ParsedAttrInfoSection ParsedAttrInfoSection::Instance; |
| 8986 | static constexpr ParsedAttrInfo::Spelling SelectAnySpellings[] = { |
| 8987 | {AttributeCommonInfo::AS_Declspec, "selectany" }, |
| 8988 | {AttributeCommonInfo::AS_GNU, "selectany" }, |
| 8989 | {AttributeCommonInfo::AS_CXX11, "gnu::selectany" }, |
| 8990 | {AttributeCommonInfo::AS_C2x, "gnu::selectany" }, |
| 8991 | }; |
| 8992 | struct ParsedAttrInfoSelectAny final : public ParsedAttrInfo { |
| 8993 | ParsedAttrInfoSelectAny() { |
| 8994 | AttrKind = ParsedAttr::AT_SelectAny; |
| 8995 | NumArgs = 0; |
| 8996 | OptArgs = 0; |
| 8997 | HasCustomParsing = 0; |
| 8998 | IsTargetSpecific = 0; |
| 8999 | IsType = 0; |
| 9000 | IsStmt = 0; |
| 9001 | IsKnownToGCC = 1; |
| 9002 | IsSupportedByPragmaAttribute = 0; |
| 9003 | Spellings = SelectAnySpellings; |
| 9004 | } |
| 9005 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 9006 | D->addAttr(::new (S.Context) SelectAnyAttr(S.Context, Attr)); |
| 9007 | return AttributeApplied; |
| 9008 | } |
| 9009 | |
| 9010 | static const ParsedAttrInfoSelectAny Instance; |
| 9011 | }; |
| 9012 | const ParsedAttrInfoSelectAny ParsedAttrInfoSelectAny::Instance; |
| 9013 | static constexpr ParsedAttrInfo::Spelling SentinelSpellings[] = { |
| 9014 | {AttributeCommonInfo::AS_GNU, "sentinel" }, |
| 9015 | {AttributeCommonInfo::AS_CXX11, "gnu::sentinel" }, |
| 9016 | {AttributeCommonInfo::AS_C2x, "gnu::sentinel" }, |
| 9017 | }; |
| 9018 | struct ParsedAttrInfoSentinel final : public ParsedAttrInfo { |
| 9019 | ParsedAttrInfoSentinel() { |
| 9020 | AttrKind = ParsedAttr::AT_Sentinel; |
| 9021 | NumArgs = 0; |
| 9022 | OptArgs = 2; |
| 9023 | HasCustomParsing = 0; |
| 9024 | IsTargetSpecific = 0; |
| 9025 | IsType = 0; |
| 9026 | IsStmt = 0; |
| 9027 | IsKnownToGCC = 1; |
| 9028 | IsSupportedByPragmaAttribute = 0; |
| 9029 | Spellings = SentinelSpellings; |
| 9030 | } |
| 9031 | static const ParsedAttrInfoSentinel Instance; |
| 9032 | }; |
| 9033 | const ParsedAttrInfoSentinel ParsedAttrInfoSentinel::Instance; |
| 9034 | static constexpr ParsedAttrInfo::Spelling SetTypestateSpellings[] = { |
| 9035 | {AttributeCommonInfo::AS_GNU, "set_typestate" }, |
| 9036 | {AttributeCommonInfo::AS_CXX11, "clang::set_typestate" }, |
| 9037 | }; |
| 9038 | struct ParsedAttrInfoSetTypestate final : public ParsedAttrInfo { |
| 9039 | ParsedAttrInfoSetTypestate() { |
| 9040 | AttrKind = ParsedAttr::AT_SetTypestate; |
| 9041 | NumArgs = 1; |
| 9042 | OptArgs = 0; |
| 9043 | HasCustomParsing = 0; |
| 9044 | IsTargetSpecific = 0; |
| 9045 | IsType = 0; |
| 9046 | IsStmt = 0; |
| 9047 | IsKnownToGCC = 0; |
| 9048 | IsSupportedByPragmaAttribute = 1; |
| 9049 | Spellings = SetTypestateSpellings; |
| 9050 | } |
| 9051 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9052 | if (!isa<CXXMethodDecl>(D)) { |
| 9053 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 9054 | << Attr << "functions" ; |
| 9055 | return false; |
| 9056 | } |
| 9057 | return true; |
| 9058 | } |
| 9059 | |
| 9060 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9061 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function_is_member, /*IsSupported=*/LangOpts.CPlusPlus)); |
| 9062 | } |
| 9063 | |
| 9064 | static const ParsedAttrInfoSetTypestate Instance; |
| 9065 | }; |
| 9066 | const ParsedAttrInfoSetTypestate ParsedAttrInfoSetTypestate::Instance; |
| 9067 | static constexpr ParsedAttrInfo::Spelling SharedTrylockFunctionSpellings[] = { |
| 9068 | {AttributeCommonInfo::AS_GNU, "shared_trylock_function" }, |
| 9069 | }; |
| 9070 | struct ParsedAttrInfoSharedTrylockFunction final : public ParsedAttrInfo { |
| 9071 | ParsedAttrInfoSharedTrylockFunction() { |
| 9072 | AttrKind = ParsedAttr::AT_SharedTrylockFunction; |
| 9073 | NumArgs = 1; |
| 9074 | OptArgs = 15; |
| 9075 | HasCustomParsing = 0; |
| 9076 | IsTargetSpecific = 0; |
| 9077 | IsType = 0; |
| 9078 | IsStmt = 0; |
| 9079 | IsKnownToGCC = 0; |
| 9080 | IsSupportedByPragmaAttribute = 0; |
| 9081 | Spellings = SharedTrylockFunctionSpellings; |
| 9082 | } |
| 9083 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9084 | if (!isa<FunctionDecl>(D)) { |
| 9085 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 9086 | << Attr << "functions" ; |
| 9087 | return false; |
| 9088 | } |
| 9089 | return true; |
| 9090 | } |
| 9091 | |
| 9092 | static const ParsedAttrInfoSharedTrylockFunction Instance; |
| 9093 | }; |
| 9094 | const ParsedAttrInfoSharedTrylockFunction ParsedAttrInfoSharedTrylockFunction::Instance; |
| 9095 | static constexpr ParsedAttrInfo::Spelling SpeculativeLoadHardeningSpellings[] = { |
| 9096 | {AttributeCommonInfo::AS_GNU, "speculative_load_hardening" }, |
| 9097 | {AttributeCommonInfo::AS_CXX11, "clang::speculative_load_hardening" }, |
| 9098 | {AttributeCommonInfo::AS_C2x, "clang::speculative_load_hardening" }, |
| 9099 | }; |
| 9100 | struct ParsedAttrInfoSpeculativeLoadHardening final : public ParsedAttrInfo { |
| 9101 | ParsedAttrInfoSpeculativeLoadHardening() { |
| 9102 | AttrKind = ParsedAttr::AT_SpeculativeLoadHardening; |
| 9103 | NumArgs = 0; |
| 9104 | OptArgs = 0; |
| 9105 | HasCustomParsing = 0; |
| 9106 | IsTargetSpecific = 0; |
| 9107 | IsType = 0; |
| 9108 | IsStmt = 0; |
| 9109 | IsKnownToGCC = 0; |
| 9110 | IsSupportedByPragmaAttribute = 1; |
| 9111 | Spellings = SpeculativeLoadHardeningSpellings; |
| 9112 | } |
| 9113 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9114 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 9115 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 9116 | << Attr << "functions and Objective-C methods" ; |
| 9117 | return false; |
| 9118 | } |
| 9119 | return true; |
| 9120 | } |
| 9121 | |
| 9122 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9123 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 9124 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 9125 | } |
| 9126 | |
| 9127 | static const ParsedAttrInfoSpeculativeLoadHardening Instance; |
| 9128 | }; |
| 9129 | const ParsedAttrInfoSpeculativeLoadHardening ParsedAttrInfoSpeculativeLoadHardening::Instance; |
| 9130 | static constexpr ParsedAttrInfo::Spelling StdCallSpellings[] = { |
| 9131 | {AttributeCommonInfo::AS_GNU, "stdcall" }, |
| 9132 | {AttributeCommonInfo::AS_CXX11, "gnu::stdcall" }, |
| 9133 | {AttributeCommonInfo::AS_C2x, "gnu::stdcall" }, |
| 9134 | {AttributeCommonInfo::AS_Keyword, "__stdcall" }, |
| 9135 | {AttributeCommonInfo::AS_Keyword, "_stdcall" }, |
| 9136 | }; |
| 9137 | struct ParsedAttrInfoStdCall final : public ParsedAttrInfo { |
| 9138 | ParsedAttrInfoStdCall() { |
| 9139 | AttrKind = ParsedAttr::AT_StdCall; |
| 9140 | NumArgs = 0; |
| 9141 | OptArgs = 0; |
| 9142 | HasCustomParsing = 0; |
| 9143 | IsTargetSpecific = 0; |
| 9144 | IsType = 1; |
| 9145 | IsStmt = 0; |
| 9146 | IsKnownToGCC = 1; |
| 9147 | IsSupportedByPragmaAttribute = 0; |
| 9148 | Spellings = StdCallSpellings; |
| 9149 | } |
| 9150 | static const ParsedAttrInfoStdCall Instance; |
| 9151 | }; |
| 9152 | const ParsedAttrInfoStdCall ParsedAttrInfoStdCall::Instance; |
| 9153 | struct ParsedAttrInfoStrictFP final : public ParsedAttrInfo { |
| 9154 | ParsedAttrInfoStrictFP() { |
| 9155 | AttrKind = ParsedAttr::AT_StrictFP; |
| 9156 | NumArgs = 0; |
| 9157 | OptArgs = 0; |
| 9158 | HasCustomParsing = 0; |
| 9159 | IsTargetSpecific = 0; |
| 9160 | IsType = 0; |
| 9161 | IsStmt = 0; |
| 9162 | IsKnownToGCC = 0; |
| 9163 | IsSupportedByPragmaAttribute = 0; |
| 9164 | } |
| 9165 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9166 | if (!isa<FunctionDecl>(D)) { |
| 9167 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 9168 | << Attr << "functions" ; |
| 9169 | return false; |
| 9170 | } |
| 9171 | return true; |
| 9172 | } |
| 9173 | |
| 9174 | static const ParsedAttrInfoStrictFP Instance; |
| 9175 | }; |
| 9176 | const ParsedAttrInfoStrictFP ParsedAttrInfoStrictFP::Instance; |
| 9177 | static constexpr ParsedAttrInfo::Spelling SuppressSpellings[] = { |
| 9178 | {AttributeCommonInfo::AS_CXX11, "gsl::suppress" }, |
| 9179 | }; |
| 9180 | struct ParsedAttrInfoSuppress final : public ParsedAttrInfo { |
| 9181 | ParsedAttrInfoSuppress() { |
| 9182 | AttrKind = ParsedAttr::AT_Suppress; |
| 9183 | NumArgs = 0; |
| 9184 | OptArgs = 15; |
| 9185 | HasCustomParsing = 0; |
| 9186 | IsTargetSpecific = 0; |
| 9187 | IsType = 0; |
| 9188 | IsStmt = 1; |
| 9189 | IsKnownToGCC = 0; |
| 9190 | IsSupportedByPragmaAttribute = 0; |
| 9191 | Spellings = SuppressSpellings; |
| 9192 | } |
| 9193 | static const ParsedAttrInfoSuppress Instance; |
| 9194 | }; |
| 9195 | const ParsedAttrInfoSuppress ParsedAttrInfoSuppress::Instance; |
| 9196 | static constexpr ParsedAttrInfo::Spelling SwiftAsyncSpellings[] = { |
| 9197 | {AttributeCommonInfo::AS_GNU, "swift_async" }, |
| 9198 | {AttributeCommonInfo::AS_CXX11, "clang::swift_async" }, |
| 9199 | {AttributeCommonInfo::AS_C2x, "clang::swift_async" }, |
| 9200 | }; |
| 9201 | struct ParsedAttrInfoSwiftAsync final : public ParsedAttrInfo { |
| 9202 | ParsedAttrInfoSwiftAsync() { |
| 9203 | AttrKind = ParsedAttr::AT_SwiftAsync; |
| 9204 | NumArgs = 1; |
| 9205 | OptArgs = 1; |
| 9206 | HasCustomParsing = 0; |
| 9207 | IsTargetSpecific = 0; |
| 9208 | IsType = 0; |
| 9209 | IsStmt = 0; |
| 9210 | IsKnownToGCC = 0; |
| 9211 | IsSupportedByPragmaAttribute = 1; |
| 9212 | Spellings = SwiftAsyncSpellings; |
| 9213 | } |
| 9214 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9215 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 9216 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 9217 | << Attr << "functions and Objective-C methods" ; |
| 9218 | return false; |
| 9219 | } |
| 9220 | return true; |
| 9221 | } |
| 9222 | |
| 9223 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9224 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 9225 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 9226 | } |
| 9227 | |
| 9228 | static const ParsedAttrInfoSwiftAsync Instance; |
| 9229 | }; |
| 9230 | const ParsedAttrInfoSwiftAsync ParsedAttrInfoSwiftAsync::Instance; |
| 9231 | static constexpr ParsedAttrInfo::Spelling SwiftAsyncNameSpellings[] = { |
| 9232 | {AttributeCommonInfo::AS_GNU, "swift_async_name" }, |
| 9233 | }; |
| 9234 | struct ParsedAttrInfoSwiftAsyncName final : public ParsedAttrInfo { |
| 9235 | ParsedAttrInfoSwiftAsyncName() { |
| 9236 | AttrKind = ParsedAttr::AT_SwiftAsyncName; |
| 9237 | NumArgs = 1; |
| 9238 | OptArgs = 0; |
| 9239 | HasCustomParsing = 0; |
| 9240 | IsTargetSpecific = 0; |
| 9241 | IsType = 0; |
| 9242 | IsStmt = 0; |
| 9243 | IsKnownToGCC = 0; |
| 9244 | IsSupportedByPragmaAttribute = 1; |
| 9245 | Spellings = SwiftAsyncNameSpellings; |
| 9246 | } |
| 9247 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9248 | if (!isa<ObjCMethodDecl>(D) && !isa<FunctionDecl>(D)) { |
| 9249 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 9250 | << Attr << "Objective-C methods and functions" ; |
| 9251 | return false; |
| 9252 | } |
| 9253 | return true; |
| 9254 | } |
| 9255 | |
| 9256 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9257 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 9258 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 9259 | } |
| 9260 | |
| 9261 | static const ParsedAttrInfoSwiftAsyncName Instance; |
| 9262 | }; |
| 9263 | const ParsedAttrInfoSwiftAsyncName ParsedAttrInfoSwiftAsyncName::Instance; |
| 9264 | static constexpr ParsedAttrInfo::Spelling SwiftAttrSpellings[] = { |
| 9265 | {AttributeCommonInfo::AS_GNU, "swift_attr" }, |
| 9266 | }; |
| 9267 | struct ParsedAttrInfoSwiftAttr final : public ParsedAttrInfo { |
| 9268 | ParsedAttrInfoSwiftAttr() { |
| 9269 | AttrKind = ParsedAttr::AT_SwiftAttr; |
| 9270 | NumArgs = 1; |
| 9271 | OptArgs = 0; |
| 9272 | HasCustomParsing = 0; |
| 9273 | IsTargetSpecific = 0; |
| 9274 | IsType = 0; |
| 9275 | IsStmt = 0; |
| 9276 | IsKnownToGCC = 0; |
| 9277 | IsSupportedByPragmaAttribute = 0; |
| 9278 | Spellings = SwiftAttrSpellings; |
| 9279 | } |
| 9280 | static const ParsedAttrInfoSwiftAttr Instance; |
| 9281 | }; |
| 9282 | const ParsedAttrInfoSwiftAttr ParsedAttrInfoSwiftAttr::Instance; |
| 9283 | static constexpr ParsedAttrInfo::Spelling SwiftBridgeSpellings[] = { |
| 9284 | {AttributeCommonInfo::AS_GNU, "swift_bridge" }, |
| 9285 | }; |
| 9286 | struct ParsedAttrInfoSwiftBridge final : public ParsedAttrInfo { |
| 9287 | ParsedAttrInfoSwiftBridge() { |
| 9288 | AttrKind = ParsedAttr::AT_SwiftBridge; |
| 9289 | NumArgs = 1; |
| 9290 | OptArgs = 0; |
| 9291 | HasCustomParsing = 0; |
| 9292 | IsTargetSpecific = 0; |
| 9293 | IsType = 0; |
| 9294 | IsStmt = 0; |
| 9295 | IsKnownToGCC = 0; |
| 9296 | IsSupportedByPragmaAttribute = 0; |
| 9297 | Spellings = SwiftBridgeSpellings; |
| 9298 | } |
| 9299 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9300 | if (!isa<TagDecl>(D) && !isa<TypedefNameDecl>(D) && !isa<ObjCInterfaceDecl>(D) && !isa<ObjCProtocolDecl>(D)) { |
| 9301 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 9302 | << Attr << "tag types, typedefs, Objective-C interfaces, and Objective-C protocols" ; |
| 9303 | return false; |
| 9304 | } |
| 9305 | return true; |
| 9306 | } |
| 9307 | |
| 9308 | static const ParsedAttrInfoSwiftBridge Instance; |
| 9309 | }; |
| 9310 | const ParsedAttrInfoSwiftBridge ParsedAttrInfoSwiftBridge::Instance; |
| 9311 | static constexpr ParsedAttrInfo::Spelling SwiftBridgedTypedefSpellings[] = { |
| 9312 | {AttributeCommonInfo::AS_GNU, "swift_bridged_typedef" }, |
| 9313 | }; |
| 9314 | struct ParsedAttrInfoSwiftBridgedTypedef final : public ParsedAttrInfo { |
| 9315 | ParsedAttrInfoSwiftBridgedTypedef() { |
| 9316 | AttrKind = ParsedAttr::AT_SwiftBridgedTypedef; |
| 9317 | NumArgs = 0; |
| 9318 | OptArgs = 0; |
| 9319 | HasCustomParsing = 0; |
| 9320 | IsTargetSpecific = 0; |
| 9321 | IsType = 0; |
| 9322 | IsStmt = 0; |
| 9323 | IsKnownToGCC = 0; |
| 9324 | IsSupportedByPragmaAttribute = 1; |
| 9325 | Spellings = SwiftBridgedTypedefSpellings; |
| 9326 | } |
| 9327 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9328 | if (!isa<TypedefNameDecl>(D)) { |
| 9329 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 9330 | << Attr << "typedefs" ; |
| 9331 | return false; |
| 9332 | } |
| 9333 | return true; |
| 9334 | } |
| 9335 | |
| 9336 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9337 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
| 9338 | } |
| 9339 | |
| 9340 | static const ParsedAttrInfoSwiftBridgedTypedef Instance; |
| 9341 | }; |
| 9342 | const ParsedAttrInfoSwiftBridgedTypedef ParsedAttrInfoSwiftBridgedTypedef::Instance; |
| 9343 | static constexpr ParsedAttrInfo::Spelling SwiftCallSpellings[] = { |
| 9344 | {AttributeCommonInfo::AS_GNU, "swiftcall" }, |
| 9345 | {AttributeCommonInfo::AS_CXX11, "clang::swiftcall" }, |
| 9346 | {AttributeCommonInfo::AS_C2x, "clang::swiftcall" }, |
| 9347 | }; |
| 9348 | struct ParsedAttrInfoSwiftCall final : public ParsedAttrInfo { |
| 9349 | ParsedAttrInfoSwiftCall() { |
| 9350 | AttrKind = ParsedAttr::AT_SwiftCall; |
| 9351 | NumArgs = 0; |
| 9352 | OptArgs = 0; |
| 9353 | HasCustomParsing = 0; |
| 9354 | IsTargetSpecific = 0; |
| 9355 | IsType = 1; |
| 9356 | IsStmt = 0; |
| 9357 | IsKnownToGCC = 0; |
| 9358 | IsSupportedByPragmaAttribute = 0; |
| 9359 | Spellings = SwiftCallSpellings; |
| 9360 | } |
| 9361 | static const ParsedAttrInfoSwiftCall Instance; |
| 9362 | }; |
| 9363 | const ParsedAttrInfoSwiftCall ParsedAttrInfoSwiftCall::Instance; |
| 9364 | static constexpr ParsedAttrInfo::Spelling SwiftContextSpellings[] = { |
| 9365 | {AttributeCommonInfo::AS_GNU, "swift_context" }, |
| 9366 | {AttributeCommonInfo::AS_CXX11, "clang::swift_context" }, |
| 9367 | {AttributeCommonInfo::AS_C2x, "clang::swift_context" }, |
| 9368 | }; |
| 9369 | struct ParsedAttrInfoSwiftContext final : public ParsedAttrInfo { |
| 9370 | ParsedAttrInfoSwiftContext() { |
| 9371 | AttrKind = ParsedAttr::AT_SwiftContext; |
| 9372 | NumArgs = 0; |
| 9373 | OptArgs = 0; |
| 9374 | HasCustomParsing = 0; |
| 9375 | IsTargetSpecific = 0; |
| 9376 | IsType = 0; |
| 9377 | IsStmt = 0; |
| 9378 | IsKnownToGCC = 0; |
| 9379 | IsSupportedByPragmaAttribute = 1; |
| 9380 | Spellings = SwiftContextSpellings; |
| 9381 | } |
| 9382 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9383 | if (!isa<ParmVarDecl>(D)) { |
| 9384 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 9385 | << Attr << "parameters" ; |
| 9386 | return false; |
| 9387 | } |
| 9388 | return true; |
| 9389 | } |
| 9390 | |
| 9391 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9392 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 9393 | } |
| 9394 | |
| 9395 | static const ParsedAttrInfoSwiftContext Instance; |
| 9396 | }; |
| 9397 | const ParsedAttrInfoSwiftContext ParsedAttrInfoSwiftContext::Instance; |
| 9398 | static constexpr ParsedAttrInfo::Spelling SwiftErrorSpellings[] = { |
| 9399 | {AttributeCommonInfo::AS_GNU, "swift_error" }, |
| 9400 | }; |
| 9401 | struct ParsedAttrInfoSwiftError final : public ParsedAttrInfo { |
| 9402 | ParsedAttrInfoSwiftError() { |
| 9403 | AttrKind = ParsedAttr::AT_SwiftError; |
| 9404 | NumArgs = 1; |
| 9405 | OptArgs = 0; |
| 9406 | HasCustomParsing = 0; |
| 9407 | IsTargetSpecific = 0; |
| 9408 | IsType = 0; |
| 9409 | IsStmt = 0; |
| 9410 | IsKnownToGCC = 0; |
| 9411 | IsSupportedByPragmaAttribute = 1; |
| 9412 | Spellings = SwiftErrorSpellings; |
| 9413 | } |
| 9414 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9415 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 9416 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 9417 | << Attr << "functions and Objective-C methods" ; |
| 9418 | return false; |
| 9419 | } |
| 9420 | return true; |
| 9421 | } |
| 9422 | |
| 9423 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9424 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 9425 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 9426 | } |
| 9427 | |
| 9428 | static const ParsedAttrInfoSwiftError Instance; |
| 9429 | }; |
| 9430 | const ParsedAttrInfoSwiftError ParsedAttrInfoSwiftError::Instance; |
| 9431 | static constexpr ParsedAttrInfo::Spelling SwiftErrorResultSpellings[] = { |
| 9432 | {AttributeCommonInfo::AS_GNU, "swift_error_result" }, |
| 9433 | {AttributeCommonInfo::AS_CXX11, "clang::swift_error_result" }, |
| 9434 | {AttributeCommonInfo::AS_C2x, "clang::swift_error_result" }, |
| 9435 | }; |
| 9436 | struct ParsedAttrInfoSwiftErrorResult final : public ParsedAttrInfo { |
| 9437 | ParsedAttrInfoSwiftErrorResult() { |
| 9438 | AttrKind = ParsedAttr::AT_SwiftErrorResult; |
| 9439 | NumArgs = 0; |
| 9440 | OptArgs = 0; |
| 9441 | HasCustomParsing = 0; |
| 9442 | IsTargetSpecific = 0; |
| 9443 | IsType = 0; |
| 9444 | IsStmt = 0; |
| 9445 | IsKnownToGCC = 0; |
| 9446 | IsSupportedByPragmaAttribute = 1; |
| 9447 | Spellings = SwiftErrorResultSpellings; |
| 9448 | } |
| 9449 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9450 | if (!isa<ParmVarDecl>(D)) { |
| 9451 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 9452 | << Attr << "parameters" ; |
| 9453 | return false; |
| 9454 | } |
| 9455 | return true; |
| 9456 | } |
| 9457 | |
| 9458 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9459 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 9460 | } |
| 9461 | |
| 9462 | static const ParsedAttrInfoSwiftErrorResult Instance; |
| 9463 | }; |
| 9464 | const ParsedAttrInfoSwiftErrorResult ParsedAttrInfoSwiftErrorResult::Instance; |
| 9465 | static constexpr ParsedAttrInfo::Spelling SwiftIndirectResultSpellings[] = { |
| 9466 | {AttributeCommonInfo::AS_GNU, "swift_indirect_result" }, |
| 9467 | {AttributeCommonInfo::AS_CXX11, "clang::swift_indirect_result" }, |
| 9468 | {AttributeCommonInfo::AS_C2x, "clang::swift_indirect_result" }, |
| 9469 | }; |
| 9470 | struct ParsedAttrInfoSwiftIndirectResult final : public ParsedAttrInfo { |
| 9471 | ParsedAttrInfoSwiftIndirectResult() { |
| 9472 | AttrKind = ParsedAttr::AT_SwiftIndirectResult; |
| 9473 | NumArgs = 0; |
| 9474 | OptArgs = 0; |
| 9475 | HasCustomParsing = 0; |
| 9476 | IsTargetSpecific = 0; |
| 9477 | IsType = 0; |
| 9478 | IsStmt = 0; |
| 9479 | IsKnownToGCC = 0; |
| 9480 | IsSupportedByPragmaAttribute = 1; |
| 9481 | Spellings = SwiftIndirectResultSpellings; |
| 9482 | } |
| 9483 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9484 | if (!isa<ParmVarDecl>(D)) { |
| 9485 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 9486 | << Attr << "parameters" ; |
| 9487 | return false; |
| 9488 | } |
| 9489 | return true; |
| 9490 | } |
| 9491 | |
| 9492 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9493 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 9494 | } |
| 9495 | |
| 9496 | static const ParsedAttrInfoSwiftIndirectResult Instance; |
| 9497 | }; |
| 9498 | const ParsedAttrInfoSwiftIndirectResult ParsedAttrInfoSwiftIndirectResult::Instance; |
| 9499 | static constexpr ParsedAttrInfo::Spelling SwiftNameSpellings[] = { |
| 9500 | {AttributeCommonInfo::AS_GNU, "swift_name" }, |
| 9501 | }; |
| 9502 | struct ParsedAttrInfoSwiftName final : public ParsedAttrInfo { |
| 9503 | ParsedAttrInfoSwiftName() { |
| 9504 | AttrKind = ParsedAttr::AT_SwiftName; |
| 9505 | NumArgs = 1; |
| 9506 | OptArgs = 0; |
| 9507 | HasCustomParsing = 0; |
| 9508 | IsTargetSpecific = 0; |
| 9509 | IsType = 0; |
| 9510 | IsStmt = 0; |
| 9511 | IsKnownToGCC = 0; |
| 9512 | IsSupportedByPragmaAttribute = 0; |
| 9513 | Spellings = SwiftNameSpellings; |
| 9514 | } |
| 9515 | static const ParsedAttrInfoSwiftName Instance; |
| 9516 | }; |
| 9517 | const ParsedAttrInfoSwiftName ParsedAttrInfoSwiftName::Instance; |
| 9518 | static constexpr ParsedAttrInfo::Spelling SwiftNewTypeSpellings[] = { |
| 9519 | {AttributeCommonInfo::AS_GNU, "swift_newtype" }, |
| 9520 | {AttributeCommonInfo::AS_GNU, "swift_wrapper" }, |
| 9521 | }; |
| 9522 | struct ParsedAttrInfoSwiftNewType final : public ParsedAttrInfo { |
| 9523 | ParsedAttrInfoSwiftNewType() { |
| 9524 | AttrKind = ParsedAttr::AT_SwiftNewType; |
| 9525 | NumArgs = 1; |
| 9526 | OptArgs = 0; |
| 9527 | HasCustomParsing = 1; |
| 9528 | IsTargetSpecific = 0; |
| 9529 | IsType = 0; |
| 9530 | IsStmt = 0; |
| 9531 | IsKnownToGCC = 0; |
| 9532 | IsSupportedByPragmaAttribute = 1; |
| 9533 | Spellings = SwiftNewTypeSpellings; |
| 9534 | } |
| 9535 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9536 | if (!isa<TypedefNameDecl>(D)) { |
| 9537 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 9538 | << Attr << "typedefs" ; |
| 9539 | return false; |
| 9540 | } |
| 9541 | return true; |
| 9542 | } |
| 9543 | |
| 9544 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 9545 | enum Spelling { |
| 9546 | GNU_swift_newtype = 0, |
| 9547 | GNU_swift_wrapper = 1, |
| 9548 | SpellingNotCalculated = 15 |
| 9549 | |
| 9550 | }; |
| 9551 | |
| 9552 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 9553 | switch (Idx) { |
| 9554 | default: llvm_unreachable("Unknown spelling list index" ); |
| 9555 | case 0: return GNU_swift_newtype; |
| 9556 | case 1: return GNU_swift_wrapper; |
| 9557 | } |
| 9558 | } |
| 9559 | |
| 9560 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9561 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
| 9562 | } |
| 9563 | |
| 9564 | static const ParsedAttrInfoSwiftNewType Instance; |
| 9565 | }; |
| 9566 | const ParsedAttrInfoSwiftNewType ParsedAttrInfoSwiftNewType::Instance; |
| 9567 | static constexpr ParsedAttrInfo::Spelling [] = { |
| 9568 | {AttributeCommonInfo::AS_GNU, "swift_objc_members" }, |
| 9569 | }; |
| 9570 | struct ParsedAttrInfoSwiftObjCMembers final : public ParsedAttrInfo { |
| 9571 | ParsedAttrInfoSwiftObjCMembers() { |
| 9572 | AttrKind = ParsedAttr::AT_SwiftObjCMembers; |
| 9573 | NumArgs = 0; |
| 9574 | OptArgs = 0; |
| 9575 | HasCustomParsing = 0; |
| 9576 | IsTargetSpecific = 0; |
| 9577 | IsType = 0; |
| 9578 | IsStmt = 0; |
| 9579 | IsKnownToGCC = 0; |
| 9580 | IsSupportedByPragmaAttribute = 1; |
| 9581 | Spellings = SwiftObjCMembersSpellings; |
| 9582 | } |
| 9583 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9584 | if (!isa<ObjCInterfaceDecl>(D)) { |
| 9585 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 9586 | << Attr << "Objective-C interfaces" ; |
| 9587 | return false; |
| 9588 | } |
| 9589 | return true; |
| 9590 | } |
| 9591 | |
| 9592 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9593 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
| 9594 | } |
| 9595 | |
| 9596 | static const ParsedAttrInfoSwiftObjCMembers Instance; |
| 9597 | }; |
| 9598 | const ParsedAttrInfoSwiftObjCMembers ParsedAttrInfoSwiftObjCMembers::Instance; |
| 9599 | static constexpr ParsedAttrInfo::Spelling SwiftPrivateSpellings[] = { |
| 9600 | {AttributeCommonInfo::AS_GNU, "swift_private" }, |
| 9601 | }; |
| 9602 | struct ParsedAttrInfoSwiftPrivate final : public ParsedAttrInfo { |
| 9603 | ParsedAttrInfoSwiftPrivate() { |
| 9604 | AttrKind = ParsedAttr::AT_SwiftPrivate; |
| 9605 | NumArgs = 0; |
| 9606 | OptArgs = 0; |
| 9607 | HasCustomParsing = 0; |
| 9608 | IsTargetSpecific = 0; |
| 9609 | IsType = 0; |
| 9610 | IsStmt = 0; |
| 9611 | IsKnownToGCC = 0; |
| 9612 | IsSupportedByPragmaAttribute = 0; |
| 9613 | Spellings = SwiftPrivateSpellings; |
| 9614 | } |
| 9615 | static const ParsedAttrInfoSwiftPrivate Instance; |
| 9616 | }; |
| 9617 | const ParsedAttrInfoSwiftPrivate ParsedAttrInfoSwiftPrivate::Instance; |
| 9618 | static constexpr ParsedAttrInfo::Spelling SysVABISpellings[] = { |
| 9619 | {AttributeCommonInfo::AS_GNU, "sysv_abi" }, |
| 9620 | {AttributeCommonInfo::AS_CXX11, "gnu::sysv_abi" }, |
| 9621 | {AttributeCommonInfo::AS_C2x, "gnu::sysv_abi" }, |
| 9622 | }; |
| 9623 | struct ParsedAttrInfoSysVABI final : public ParsedAttrInfo { |
| 9624 | ParsedAttrInfoSysVABI() { |
| 9625 | AttrKind = ParsedAttr::AT_SysVABI; |
| 9626 | NumArgs = 0; |
| 9627 | OptArgs = 0; |
| 9628 | HasCustomParsing = 0; |
| 9629 | IsTargetSpecific = 0; |
| 9630 | IsType = 1; |
| 9631 | IsStmt = 0; |
| 9632 | IsKnownToGCC = 1; |
| 9633 | IsSupportedByPragmaAttribute = 0; |
| 9634 | Spellings = SysVABISpellings; |
| 9635 | } |
| 9636 | static const ParsedAttrInfoSysVABI Instance; |
| 9637 | }; |
| 9638 | const ParsedAttrInfoSysVABI ParsedAttrInfoSysVABI::Instance; |
| 9639 | static constexpr ParsedAttrInfo::Spelling TLSModelSpellings[] = { |
| 9640 | {AttributeCommonInfo::AS_GNU, "tls_model" }, |
| 9641 | {AttributeCommonInfo::AS_CXX11, "gnu::tls_model" }, |
| 9642 | {AttributeCommonInfo::AS_C2x, "gnu::tls_model" }, |
| 9643 | }; |
| 9644 | struct ParsedAttrInfoTLSModel final : public ParsedAttrInfo { |
| 9645 | ParsedAttrInfoTLSModel() { |
| 9646 | AttrKind = ParsedAttr::AT_TLSModel; |
| 9647 | NumArgs = 1; |
| 9648 | OptArgs = 0; |
| 9649 | HasCustomParsing = 0; |
| 9650 | IsTargetSpecific = 0; |
| 9651 | IsType = 0; |
| 9652 | IsStmt = 0; |
| 9653 | IsKnownToGCC = 1; |
| 9654 | IsSupportedByPragmaAttribute = 1; |
| 9655 | Spellings = TLSModelSpellings; |
| 9656 | } |
| 9657 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9658 | if (!isTLSVar(D)) { |
| 9659 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 9660 | << Attr << "thread-local variables" ; |
| 9661 | return false; |
| 9662 | } |
| 9663 | return true; |
| 9664 | } |
| 9665 | |
| 9666 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9667 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_thread_local, /*IsSupported=*/true)); |
| 9668 | } |
| 9669 | |
| 9670 | static const ParsedAttrInfoTLSModel Instance; |
| 9671 | }; |
| 9672 | const ParsedAttrInfoTLSModel ParsedAttrInfoTLSModel::Instance; |
| 9673 | static constexpr ParsedAttrInfo::Spelling TargetSpellings[] = { |
| 9674 | {AttributeCommonInfo::AS_GNU, "target" }, |
| 9675 | {AttributeCommonInfo::AS_CXX11, "gnu::target" }, |
| 9676 | {AttributeCommonInfo::AS_C2x, "gnu::target" }, |
| 9677 | }; |
| 9678 | struct ParsedAttrInfoTarget final : public ParsedAttrInfo { |
| 9679 | ParsedAttrInfoTarget() { |
| 9680 | AttrKind = ParsedAttr::AT_Target; |
| 9681 | NumArgs = 1; |
| 9682 | OptArgs = 0; |
| 9683 | HasCustomParsing = 0; |
| 9684 | IsTargetSpecific = 0; |
| 9685 | IsType = 0; |
| 9686 | IsStmt = 0; |
| 9687 | IsKnownToGCC = 1; |
| 9688 | IsSupportedByPragmaAttribute = 1; |
| 9689 | Spellings = TargetSpellings; |
| 9690 | } |
| 9691 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9692 | if (!isa<FunctionDecl>(D)) { |
| 9693 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 9694 | << Attr << "functions" ; |
| 9695 | return false; |
| 9696 | } |
| 9697 | return true; |
| 9698 | } |
| 9699 | |
| 9700 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9701 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 9702 | } |
| 9703 | |
| 9704 | static const ParsedAttrInfoTarget Instance; |
| 9705 | }; |
| 9706 | const ParsedAttrInfoTarget ParsedAttrInfoTarget::Instance; |
| 9707 | static constexpr ParsedAttrInfo::Spelling TestTypestateSpellings[] = { |
| 9708 | {AttributeCommonInfo::AS_GNU, "test_typestate" }, |
| 9709 | {AttributeCommonInfo::AS_CXX11, "clang::test_typestate" }, |
| 9710 | }; |
| 9711 | struct ParsedAttrInfoTestTypestate final : public ParsedAttrInfo { |
| 9712 | ParsedAttrInfoTestTypestate() { |
| 9713 | AttrKind = ParsedAttr::AT_TestTypestate; |
| 9714 | NumArgs = 1; |
| 9715 | OptArgs = 0; |
| 9716 | HasCustomParsing = 0; |
| 9717 | IsTargetSpecific = 0; |
| 9718 | IsType = 0; |
| 9719 | IsStmt = 0; |
| 9720 | IsKnownToGCC = 0; |
| 9721 | IsSupportedByPragmaAttribute = 1; |
| 9722 | Spellings = TestTypestateSpellings; |
| 9723 | } |
| 9724 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9725 | if (!isa<CXXMethodDecl>(D)) { |
| 9726 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 9727 | << Attr << "functions" ; |
| 9728 | return false; |
| 9729 | } |
| 9730 | return true; |
| 9731 | } |
| 9732 | |
| 9733 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9734 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function_is_member, /*IsSupported=*/LangOpts.CPlusPlus)); |
| 9735 | } |
| 9736 | |
| 9737 | static const ParsedAttrInfoTestTypestate Instance; |
| 9738 | }; |
| 9739 | const ParsedAttrInfoTestTypestate ParsedAttrInfoTestTypestate::Instance; |
| 9740 | static constexpr ParsedAttrInfo::Spelling ThisCallSpellings[] = { |
| 9741 | {AttributeCommonInfo::AS_GNU, "thiscall" }, |
| 9742 | {AttributeCommonInfo::AS_CXX11, "gnu::thiscall" }, |
| 9743 | {AttributeCommonInfo::AS_C2x, "gnu::thiscall" }, |
| 9744 | {AttributeCommonInfo::AS_Keyword, "__thiscall" }, |
| 9745 | {AttributeCommonInfo::AS_Keyword, "_thiscall" }, |
| 9746 | }; |
| 9747 | struct ParsedAttrInfoThisCall final : public ParsedAttrInfo { |
| 9748 | ParsedAttrInfoThisCall() { |
| 9749 | AttrKind = ParsedAttr::AT_ThisCall; |
| 9750 | NumArgs = 0; |
| 9751 | OptArgs = 0; |
| 9752 | HasCustomParsing = 0; |
| 9753 | IsTargetSpecific = 0; |
| 9754 | IsType = 1; |
| 9755 | IsStmt = 0; |
| 9756 | IsKnownToGCC = 1; |
| 9757 | IsSupportedByPragmaAttribute = 0; |
| 9758 | Spellings = ThisCallSpellings; |
| 9759 | } |
| 9760 | static const ParsedAttrInfoThisCall Instance; |
| 9761 | }; |
| 9762 | const ParsedAttrInfoThisCall ParsedAttrInfoThisCall::Instance; |
| 9763 | static constexpr ParsedAttrInfo::Spelling ThreadSpellings[] = { |
| 9764 | {AttributeCommonInfo::AS_Declspec, "thread" }, |
| 9765 | }; |
| 9766 | struct ParsedAttrInfoThread final : public ParsedAttrInfo { |
| 9767 | ParsedAttrInfoThread() { |
| 9768 | AttrKind = ParsedAttr::AT_Thread; |
| 9769 | NumArgs = 0; |
| 9770 | OptArgs = 0; |
| 9771 | HasCustomParsing = 0; |
| 9772 | IsTargetSpecific = 0; |
| 9773 | IsType = 0; |
| 9774 | IsStmt = 0; |
| 9775 | IsKnownToGCC = 0; |
| 9776 | IsSupportedByPragmaAttribute = 0; |
| 9777 | Spellings = ThreadSpellings; |
| 9778 | } |
| 9779 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9780 | if (!isa<VarDecl>(D)) { |
| 9781 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 9782 | << Attr << "variables" ; |
| 9783 | return false; |
| 9784 | } |
| 9785 | return true; |
| 9786 | } |
| 9787 | |
| 9788 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 9789 | auto &LangOpts = S.LangOpts; |
| 9790 | if (LangOpts.MicrosoftExt) |
| 9791 | return true; |
| 9792 | |
| 9793 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 9794 | return false; |
| 9795 | } |
| 9796 | |
| 9797 | static const ParsedAttrInfoThread Instance; |
| 9798 | }; |
| 9799 | const ParsedAttrInfoThread ParsedAttrInfoThread::Instance; |
| 9800 | static constexpr ParsedAttrInfo::Spelling TransparentUnionSpellings[] = { |
| 9801 | {AttributeCommonInfo::AS_GNU, "transparent_union" }, |
| 9802 | {AttributeCommonInfo::AS_CXX11, "gnu::transparent_union" }, |
| 9803 | {AttributeCommonInfo::AS_C2x, "gnu::transparent_union" }, |
| 9804 | }; |
| 9805 | struct ParsedAttrInfoTransparentUnion final : public ParsedAttrInfo { |
| 9806 | ParsedAttrInfoTransparentUnion() { |
| 9807 | AttrKind = ParsedAttr::AT_TransparentUnion; |
| 9808 | NumArgs = 0; |
| 9809 | OptArgs = 0; |
| 9810 | HasCustomParsing = 0; |
| 9811 | IsTargetSpecific = 0; |
| 9812 | IsType = 0; |
| 9813 | IsStmt = 0; |
| 9814 | IsKnownToGCC = 1; |
| 9815 | IsSupportedByPragmaAttribute = 0; |
| 9816 | Spellings = TransparentUnionSpellings; |
| 9817 | } |
| 9818 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 9819 | auto &LangOpts = S.LangOpts; |
| 9820 | if ((!LangOpts.CPlusPlus)) |
| 9821 | return true; |
| 9822 | |
| 9823 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 9824 | return false; |
| 9825 | } |
| 9826 | |
| 9827 | static const ParsedAttrInfoTransparentUnion Instance; |
| 9828 | }; |
| 9829 | const ParsedAttrInfoTransparentUnion ParsedAttrInfoTransparentUnion::Instance; |
| 9830 | static constexpr ParsedAttrInfo::Spelling TrivialABISpellings[] = { |
| 9831 | {AttributeCommonInfo::AS_GNU, "trivial_abi" }, |
| 9832 | {AttributeCommonInfo::AS_CXX11, "clang::trivial_abi" }, |
| 9833 | }; |
| 9834 | struct ParsedAttrInfoTrivialABI final : public ParsedAttrInfo { |
| 9835 | ParsedAttrInfoTrivialABI() { |
| 9836 | AttrKind = ParsedAttr::AT_TrivialABI; |
| 9837 | NumArgs = 0; |
| 9838 | OptArgs = 0; |
| 9839 | HasCustomParsing = 0; |
| 9840 | IsTargetSpecific = 0; |
| 9841 | IsType = 0; |
| 9842 | IsStmt = 0; |
| 9843 | IsKnownToGCC = 0; |
| 9844 | IsSupportedByPragmaAttribute = 1; |
| 9845 | Spellings = TrivialABISpellings; |
| 9846 | } |
| 9847 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9848 | if (!isa<CXXRecordDecl>(D)) { |
| 9849 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 9850 | << Attr << "classes" ; |
| 9851 | return false; |
| 9852 | } |
| 9853 | return true; |
| 9854 | } |
| 9855 | |
| 9856 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 9857 | auto &LangOpts = S.LangOpts; |
| 9858 | if (LangOpts.CPlusPlus) |
| 9859 | return true; |
| 9860 | |
| 9861 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 9862 | return false; |
| 9863 | } |
| 9864 | |
| 9865 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 9866 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 9867 | } |
| 9868 | |
| 9869 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 9870 | D->addAttr(::new (S.Context) TrivialABIAttr(S.Context, Attr)); |
| 9871 | return AttributeApplied; |
| 9872 | } |
| 9873 | |
| 9874 | static const ParsedAttrInfoTrivialABI Instance; |
| 9875 | }; |
| 9876 | const ParsedAttrInfoTrivialABI ParsedAttrInfoTrivialABI::Instance; |
| 9877 | static constexpr ParsedAttrInfo::Spelling TryAcquireCapabilitySpellings[] = { |
| 9878 | {AttributeCommonInfo::AS_GNU, "try_acquire_capability" }, |
| 9879 | {AttributeCommonInfo::AS_CXX11, "clang::try_acquire_capability" }, |
| 9880 | {AttributeCommonInfo::AS_GNU, "try_acquire_shared_capability" }, |
| 9881 | {AttributeCommonInfo::AS_CXX11, "clang::try_acquire_shared_capability" }, |
| 9882 | }; |
| 9883 | struct ParsedAttrInfoTryAcquireCapability final : public ParsedAttrInfo { |
| 9884 | ParsedAttrInfoTryAcquireCapability() { |
| 9885 | AttrKind = ParsedAttr::AT_TryAcquireCapability; |
| 9886 | NumArgs = 1; |
| 9887 | OptArgs = 15; |
| 9888 | HasCustomParsing = 0; |
| 9889 | IsTargetSpecific = 0; |
| 9890 | IsType = 0; |
| 9891 | IsStmt = 0; |
| 9892 | IsKnownToGCC = 0; |
| 9893 | IsSupportedByPragmaAttribute = 0; |
| 9894 | Spellings = TryAcquireCapabilitySpellings; |
| 9895 | } |
| 9896 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 9897 | if (!isa<FunctionDecl>(D)) { |
| 9898 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 9899 | << Attr << "functions" ; |
| 9900 | return false; |
| 9901 | } |
| 9902 | return true; |
| 9903 | } |
| 9904 | |
| 9905 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 9906 | enum Spelling { |
| 9907 | GNU_try_acquire_capability = 0, |
| 9908 | CXX11_clang_try_acquire_capability = 1, |
| 9909 | GNU_try_acquire_shared_capability = 2, |
| 9910 | CXX11_clang_try_acquire_shared_capability = 3, |
| 9911 | SpellingNotCalculated = 15 |
| 9912 | |
| 9913 | }; |
| 9914 | |
| 9915 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 9916 | switch (Idx) { |
| 9917 | default: llvm_unreachable("Unknown spelling list index" ); |
| 9918 | case 0: return GNU_try_acquire_capability; |
| 9919 | case 1: return CXX11_clang_try_acquire_capability; |
| 9920 | case 2: return GNU_try_acquire_shared_capability; |
| 9921 | case 3: return CXX11_clang_try_acquire_shared_capability; |
| 9922 | } |
| 9923 | } |
| 9924 | |
| 9925 | static const ParsedAttrInfoTryAcquireCapability Instance; |
| 9926 | }; |
| 9927 | const ParsedAttrInfoTryAcquireCapability ParsedAttrInfoTryAcquireCapability::Instance; |
| 9928 | static constexpr ParsedAttrInfo::Spelling TypeNonNullSpellings[] = { |
| 9929 | {AttributeCommonInfo::AS_Keyword, "_Nonnull" }, |
| 9930 | }; |
| 9931 | struct ParsedAttrInfoTypeNonNull final : public ParsedAttrInfo { |
| 9932 | ParsedAttrInfoTypeNonNull() { |
| 9933 | AttrKind = ParsedAttr::AT_TypeNonNull; |
| 9934 | NumArgs = 0; |
| 9935 | OptArgs = 0; |
| 9936 | HasCustomParsing = 0; |
| 9937 | IsTargetSpecific = 0; |
| 9938 | IsType = 1; |
| 9939 | IsStmt = 0; |
| 9940 | IsKnownToGCC = 0; |
| 9941 | IsSupportedByPragmaAttribute = 0; |
| 9942 | Spellings = TypeNonNullSpellings; |
| 9943 | } |
| 9944 | static const ParsedAttrInfoTypeNonNull Instance; |
| 9945 | }; |
| 9946 | const ParsedAttrInfoTypeNonNull ParsedAttrInfoTypeNonNull::Instance; |
| 9947 | static constexpr ParsedAttrInfo::Spelling TypeNullUnspecifiedSpellings[] = { |
| 9948 | {AttributeCommonInfo::AS_Keyword, "_Null_unspecified" }, |
| 9949 | }; |
| 9950 | struct ParsedAttrInfoTypeNullUnspecified final : public ParsedAttrInfo { |
| 9951 | ParsedAttrInfoTypeNullUnspecified() { |
| 9952 | AttrKind = ParsedAttr::AT_TypeNullUnspecified; |
| 9953 | NumArgs = 0; |
| 9954 | OptArgs = 0; |
| 9955 | HasCustomParsing = 0; |
| 9956 | IsTargetSpecific = 0; |
| 9957 | IsType = 1; |
| 9958 | IsStmt = 0; |
| 9959 | IsKnownToGCC = 0; |
| 9960 | IsSupportedByPragmaAttribute = 0; |
| 9961 | Spellings = TypeNullUnspecifiedSpellings; |
| 9962 | } |
| 9963 | static const ParsedAttrInfoTypeNullUnspecified Instance; |
| 9964 | }; |
| 9965 | const ParsedAttrInfoTypeNullUnspecified ParsedAttrInfoTypeNullUnspecified::Instance; |
| 9966 | static constexpr ParsedAttrInfo::Spelling TypeNullableSpellings[] = { |
| 9967 | {AttributeCommonInfo::AS_Keyword, "_Nullable" }, |
| 9968 | }; |
| 9969 | struct ParsedAttrInfoTypeNullable final : public ParsedAttrInfo { |
| 9970 | ParsedAttrInfoTypeNullable() { |
| 9971 | AttrKind = ParsedAttr::AT_TypeNullable; |
| 9972 | NumArgs = 0; |
| 9973 | OptArgs = 0; |
| 9974 | HasCustomParsing = 0; |
| 9975 | IsTargetSpecific = 0; |
| 9976 | IsType = 1; |
| 9977 | IsStmt = 0; |
| 9978 | IsKnownToGCC = 0; |
| 9979 | IsSupportedByPragmaAttribute = 0; |
| 9980 | Spellings = TypeNullableSpellings; |
| 9981 | } |
| 9982 | static const ParsedAttrInfoTypeNullable Instance; |
| 9983 | }; |
| 9984 | const ParsedAttrInfoTypeNullable ParsedAttrInfoTypeNullable::Instance; |
| 9985 | static constexpr ParsedAttrInfo::Spelling TypeNullableResultSpellings[] = { |
| 9986 | {AttributeCommonInfo::AS_Keyword, "_Nullable_result" }, |
| 9987 | }; |
| 9988 | struct ParsedAttrInfoTypeNullableResult final : public ParsedAttrInfo { |
| 9989 | ParsedAttrInfoTypeNullableResult() { |
| 9990 | AttrKind = ParsedAttr::AT_TypeNullableResult; |
| 9991 | NumArgs = 0; |
| 9992 | OptArgs = 0; |
| 9993 | HasCustomParsing = 0; |
| 9994 | IsTargetSpecific = 0; |
| 9995 | IsType = 1; |
| 9996 | IsStmt = 0; |
| 9997 | IsKnownToGCC = 0; |
| 9998 | IsSupportedByPragmaAttribute = 0; |
| 9999 | Spellings = TypeNullableResultSpellings; |
| 10000 | } |
| 10001 | static const ParsedAttrInfoTypeNullableResult Instance; |
| 10002 | }; |
| 10003 | const ParsedAttrInfoTypeNullableResult ParsedAttrInfoTypeNullableResult::Instance; |
| 10004 | static constexpr ParsedAttrInfo::Spelling TypeTagForDatatypeSpellings[] = { |
| 10005 | {AttributeCommonInfo::AS_GNU, "type_tag_for_datatype" }, |
| 10006 | {AttributeCommonInfo::AS_CXX11, "clang::type_tag_for_datatype" }, |
| 10007 | {AttributeCommonInfo::AS_C2x, "clang::type_tag_for_datatype" }, |
| 10008 | }; |
| 10009 | struct ParsedAttrInfoTypeTagForDatatype final : public ParsedAttrInfo { |
| 10010 | ParsedAttrInfoTypeTagForDatatype() { |
| 10011 | AttrKind = ParsedAttr::AT_TypeTagForDatatype; |
| 10012 | NumArgs = 4; |
| 10013 | OptArgs = 0; |
| 10014 | HasCustomParsing = 1; |
| 10015 | IsTargetSpecific = 0; |
| 10016 | IsType = 0; |
| 10017 | IsStmt = 0; |
| 10018 | IsKnownToGCC = 0; |
| 10019 | IsSupportedByPragmaAttribute = 0; |
| 10020 | Spellings = TypeTagForDatatypeSpellings; |
| 10021 | } |
| 10022 | static const ParsedAttrInfoTypeTagForDatatype Instance; |
| 10023 | }; |
| 10024 | const ParsedAttrInfoTypeTagForDatatype ParsedAttrInfoTypeTagForDatatype::Instance; |
| 10025 | static constexpr ParsedAttrInfo::Spelling TypeVisibilitySpellings[] = { |
| 10026 | {AttributeCommonInfo::AS_GNU, "type_visibility" }, |
| 10027 | {AttributeCommonInfo::AS_CXX11, "clang::type_visibility" }, |
| 10028 | {AttributeCommonInfo::AS_C2x, "clang::type_visibility" }, |
| 10029 | }; |
| 10030 | struct ParsedAttrInfoTypeVisibility final : public ParsedAttrInfo { |
| 10031 | ParsedAttrInfoTypeVisibility() { |
| 10032 | AttrKind = ParsedAttr::AT_TypeVisibility; |
| 10033 | NumArgs = 1; |
| 10034 | OptArgs = 0; |
| 10035 | HasCustomParsing = 0; |
| 10036 | IsTargetSpecific = 0; |
| 10037 | IsType = 0; |
| 10038 | IsStmt = 0; |
| 10039 | IsKnownToGCC = 0; |
| 10040 | IsSupportedByPragmaAttribute = 0; |
| 10041 | Spellings = TypeVisibilitySpellings; |
| 10042 | } |
| 10043 | static const ParsedAttrInfoTypeVisibility Instance; |
| 10044 | }; |
| 10045 | const ParsedAttrInfoTypeVisibility ParsedAttrInfoTypeVisibility::Instance; |
| 10046 | static constexpr ParsedAttrInfo::Spelling UPtrSpellings[] = { |
| 10047 | {AttributeCommonInfo::AS_Keyword, "__uptr" }, |
| 10048 | }; |
| 10049 | struct ParsedAttrInfoUPtr final : public ParsedAttrInfo { |
| 10050 | ParsedAttrInfoUPtr() { |
| 10051 | AttrKind = ParsedAttr::AT_UPtr; |
| 10052 | NumArgs = 0; |
| 10053 | OptArgs = 0; |
| 10054 | HasCustomParsing = 0; |
| 10055 | IsTargetSpecific = 0; |
| 10056 | IsType = 1; |
| 10057 | IsStmt = 0; |
| 10058 | IsKnownToGCC = 0; |
| 10059 | IsSupportedByPragmaAttribute = 0; |
| 10060 | Spellings = UPtrSpellings; |
| 10061 | } |
| 10062 | static const ParsedAttrInfoUPtr Instance; |
| 10063 | }; |
| 10064 | const ParsedAttrInfoUPtr ParsedAttrInfoUPtr::Instance; |
| 10065 | static constexpr ParsedAttrInfo::Spelling UnavailableSpellings[] = { |
| 10066 | {AttributeCommonInfo::AS_GNU, "unavailable" }, |
| 10067 | {AttributeCommonInfo::AS_CXX11, "clang::unavailable" }, |
| 10068 | {AttributeCommonInfo::AS_C2x, "clang::unavailable" }, |
| 10069 | }; |
| 10070 | struct ParsedAttrInfoUnavailable final : public ParsedAttrInfo { |
| 10071 | ParsedAttrInfoUnavailable() { |
| 10072 | AttrKind = ParsedAttr::AT_Unavailable; |
| 10073 | NumArgs = 0; |
| 10074 | OptArgs = 1; |
| 10075 | HasCustomParsing = 0; |
| 10076 | IsTargetSpecific = 0; |
| 10077 | IsType = 0; |
| 10078 | IsStmt = 0; |
| 10079 | IsKnownToGCC = 0; |
| 10080 | IsSupportedByPragmaAttribute = 0; |
| 10081 | Spellings = UnavailableSpellings; |
| 10082 | } |
| 10083 | static const ParsedAttrInfoUnavailable Instance; |
| 10084 | }; |
| 10085 | const ParsedAttrInfoUnavailable ParsedAttrInfoUnavailable::Instance; |
| 10086 | static constexpr ParsedAttrInfo::Spelling UninitializedSpellings[] = { |
| 10087 | {AttributeCommonInfo::AS_GNU, "uninitialized" }, |
| 10088 | {AttributeCommonInfo::AS_CXX11, "clang::uninitialized" }, |
| 10089 | }; |
| 10090 | struct ParsedAttrInfoUninitialized final : public ParsedAttrInfo { |
| 10091 | ParsedAttrInfoUninitialized() { |
| 10092 | AttrKind = ParsedAttr::AT_Uninitialized; |
| 10093 | NumArgs = 0; |
| 10094 | OptArgs = 0; |
| 10095 | HasCustomParsing = 0; |
| 10096 | IsTargetSpecific = 0; |
| 10097 | IsType = 0; |
| 10098 | IsStmt = 0; |
| 10099 | IsKnownToGCC = 0; |
| 10100 | IsSupportedByPragmaAttribute = 1; |
| 10101 | Spellings = UninitializedSpellings; |
| 10102 | } |
| 10103 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10104 | if (!isLocalVar(D)) { |
| 10105 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 10106 | << Attr << "local variables" ; |
| 10107 | return false; |
| 10108 | } |
| 10109 | return true; |
| 10110 | } |
| 10111 | |
| 10112 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10113 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_local, /*IsSupported=*/true)); |
| 10114 | } |
| 10115 | |
| 10116 | static const ParsedAttrInfoUninitialized Instance; |
| 10117 | }; |
| 10118 | const ParsedAttrInfoUninitialized ParsedAttrInfoUninitialized::Instance; |
| 10119 | static constexpr ParsedAttrInfo::Spelling UnlikelySpellings[] = { |
| 10120 | {AttributeCommonInfo::AS_CXX11, "unlikely" }, |
| 10121 | {AttributeCommonInfo::AS_C2x, "clang::unlikely" }, |
| 10122 | }; |
| 10123 | struct ParsedAttrInfoUnlikely final : public ParsedAttrInfo { |
| 10124 | ParsedAttrInfoUnlikely() { |
| 10125 | AttrKind = ParsedAttr::AT_Unlikely; |
| 10126 | NumArgs = 0; |
| 10127 | OptArgs = 0; |
| 10128 | HasCustomParsing = 0; |
| 10129 | IsTargetSpecific = 0; |
| 10130 | IsType = 0; |
| 10131 | IsStmt = 1; |
| 10132 | IsKnownToGCC = 0; |
| 10133 | IsSupportedByPragmaAttribute = 0; |
| 10134 | Spellings = UnlikelySpellings; |
| 10135 | } |
| 10136 | static const ParsedAttrInfoUnlikely Instance; |
| 10137 | }; |
| 10138 | const ParsedAttrInfoUnlikely ParsedAttrInfoUnlikely::Instance; |
| 10139 | static constexpr ParsedAttrInfo::Spelling UnusedSpellings[] = { |
| 10140 | {AttributeCommonInfo::AS_CXX11, "maybe_unused" }, |
| 10141 | {AttributeCommonInfo::AS_GNU, "unused" }, |
| 10142 | {AttributeCommonInfo::AS_CXX11, "gnu::unused" }, |
| 10143 | {AttributeCommonInfo::AS_C2x, "gnu::unused" }, |
| 10144 | {AttributeCommonInfo::AS_C2x, "maybe_unused" }, |
| 10145 | }; |
| 10146 | struct ParsedAttrInfoUnused final : public ParsedAttrInfo { |
| 10147 | ParsedAttrInfoUnused() { |
| 10148 | AttrKind = ParsedAttr::AT_Unused; |
| 10149 | NumArgs = 0; |
| 10150 | OptArgs = 0; |
| 10151 | HasCustomParsing = 0; |
| 10152 | IsTargetSpecific = 0; |
| 10153 | IsType = 0; |
| 10154 | IsStmt = 0; |
| 10155 | IsKnownToGCC = 1; |
| 10156 | IsSupportedByPragmaAttribute = 0; |
| 10157 | Spellings = UnusedSpellings; |
| 10158 | } |
| 10159 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10160 | if (!isa<VarDecl>(D) && !isa<ObjCIvarDecl>(D) && !isa<TypeDecl>(D) && !isa<EnumDecl>(D) && !isa<EnumConstantDecl>(D) && !isa<LabelDecl>(D) && !isa<FieldDecl>(D) && !isa<ObjCMethodDecl>(D) && !isFunctionLike(D)) { |
| 10161 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 10162 | << Attr << "variables, non-static data members, types, enums, enumerators, labels, non-static data members, Objective-C methods, functions, and function pointers" ; |
| 10163 | return false; |
| 10164 | } |
| 10165 | return true; |
| 10166 | } |
| 10167 | |
| 10168 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 10169 | enum Spelling { |
| 10170 | CXX11_maybe_unused = 0, |
| 10171 | GNU_unused = 1, |
| 10172 | CXX11_gnu_unused = 2, |
| 10173 | C2x_gnu_unused = 3, |
| 10174 | C2x_maybe_unused = 4, |
| 10175 | SpellingNotCalculated = 15 |
| 10176 | |
| 10177 | }; |
| 10178 | |
| 10179 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 10180 | switch (Idx) { |
| 10181 | default: llvm_unreachable("Unknown spelling list index" ); |
| 10182 | case 0: return CXX11_maybe_unused; |
| 10183 | case 1: return GNU_unused; |
| 10184 | case 2: return CXX11_gnu_unused; |
| 10185 | case 3: return C2x_gnu_unused; |
| 10186 | case 4: return C2x_maybe_unused; |
| 10187 | } |
| 10188 | } |
| 10189 | |
| 10190 | static const ParsedAttrInfoUnused Instance; |
| 10191 | }; |
| 10192 | const ParsedAttrInfoUnused ParsedAttrInfoUnused::Instance; |
| 10193 | static constexpr ParsedAttrInfo::Spelling UseHandleSpellings[] = { |
| 10194 | {AttributeCommonInfo::AS_GNU, "use_handle" }, |
| 10195 | {AttributeCommonInfo::AS_CXX11, "clang::use_handle" }, |
| 10196 | {AttributeCommonInfo::AS_C2x, "clang::use_handle" }, |
| 10197 | }; |
| 10198 | struct ParsedAttrInfoUseHandle final : public ParsedAttrInfo { |
| 10199 | ParsedAttrInfoUseHandle() { |
| 10200 | AttrKind = ParsedAttr::AT_UseHandle; |
| 10201 | NumArgs = 1; |
| 10202 | OptArgs = 0; |
| 10203 | HasCustomParsing = 0; |
| 10204 | IsTargetSpecific = 0; |
| 10205 | IsType = 0; |
| 10206 | IsStmt = 0; |
| 10207 | IsKnownToGCC = 0; |
| 10208 | IsSupportedByPragmaAttribute = 1; |
| 10209 | Spellings = UseHandleSpellings; |
| 10210 | } |
| 10211 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10212 | if (!isa<ParmVarDecl>(D)) { |
| 10213 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 10214 | << Attr << "parameters" ; |
| 10215 | return false; |
| 10216 | } |
| 10217 | return true; |
| 10218 | } |
| 10219 | |
| 10220 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10221 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
| 10222 | } |
| 10223 | |
| 10224 | static const ParsedAttrInfoUseHandle Instance; |
| 10225 | }; |
| 10226 | const ParsedAttrInfoUseHandle ParsedAttrInfoUseHandle::Instance; |
| 10227 | static constexpr ParsedAttrInfo::Spelling UsedSpellings[] = { |
| 10228 | {AttributeCommonInfo::AS_GNU, "used" }, |
| 10229 | {AttributeCommonInfo::AS_CXX11, "gnu::used" }, |
| 10230 | {AttributeCommonInfo::AS_C2x, "gnu::used" }, |
| 10231 | }; |
| 10232 | struct ParsedAttrInfoUsed final : public ParsedAttrInfo { |
| 10233 | ParsedAttrInfoUsed() { |
| 10234 | AttrKind = ParsedAttr::AT_Used; |
| 10235 | NumArgs = 0; |
| 10236 | OptArgs = 0; |
| 10237 | HasCustomParsing = 0; |
| 10238 | IsTargetSpecific = 0; |
| 10239 | IsType = 0; |
| 10240 | IsStmt = 0; |
| 10241 | IsKnownToGCC = 1; |
| 10242 | IsSupportedByPragmaAttribute = 0; |
| 10243 | Spellings = UsedSpellings; |
| 10244 | } |
| 10245 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10246 | if (!isNonLocalVar(D) && !isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 10247 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 10248 | << Attr << "variables with non-local storage, functions, and Objective-C methods" ; |
| 10249 | return false; |
| 10250 | } |
| 10251 | return true; |
| 10252 | } |
| 10253 | |
| 10254 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 10255 | D->addAttr(::new (S.Context) UsedAttr(S.Context, Attr)); |
| 10256 | return AttributeApplied; |
| 10257 | } |
| 10258 | |
| 10259 | static const ParsedAttrInfoUsed Instance; |
| 10260 | }; |
| 10261 | const ParsedAttrInfoUsed ParsedAttrInfoUsed::Instance; |
| 10262 | static constexpr ParsedAttrInfo::Spelling UuidSpellings[] = { |
| 10263 | {AttributeCommonInfo::AS_Declspec, "uuid" }, |
| 10264 | {AttributeCommonInfo::AS_Microsoft, "uuid" }, |
| 10265 | }; |
| 10266 | struct ParsedAttrInfoUuid final : public ParsedAttrInfo { |
| 10267 | ParsedAttrInfoUuid() { |
| 10268 | AttrKind = ParsedAttr::AT_Uuid; |
| 10269 | NumArgs = 1; |
| 10270 | OptArgs = 0; |
| 10271 | HasCustomParsing = 0; |
| 10272 | IsTargetSpecific = 0; |
| 10273 | IsType = 0; |
| 10274 | IsStmt = 0; |
| 10275 | IsKnownToGCC = 0; |
| 10276 | IsSupportedByPragmaAttribute = 0; |
| 10277 | Spellings = UuidSpellings; |
| 10278 | } |
| 10279 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10280 | if (!isa<RecordDecl>(D) && !isa<EnumDecl>(D)) { |
| 10281 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 10282 | << Attr << "structs, unions, classes, and enums" ; |
| 10283 | return false; |
| 10284 | } |
| 10285 | return true; |
| 10286 | } |
| 10287 | |
| 10288 | bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const override { |
| 10289 | auto &LangOpts = S.LangOpts; |
| 10290 | if (LangOpts.MicrosoftExt || LangOpts.Borland) |
| 10291 | return true; |
| 10292 | |
| 10293 | S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr; |
| 10294 | return false; |
| 10295 | } |
| 10296 | |
| 10297 | static const ParsedAttrInfoUuid Instance; |
| 10298 | }; |
| 10299 | const ParsedAttrInfoUuid ParsedAttrInfoUuid::Instance; |
| 10300 | static constexpr ParsedAttrInfo::Spelling VecReturnSpellings[] = { |
| 10301 | {AttributeCommonInfo::AS_GNU, "vecreturn" }, |
| 10302 | {AttributeCommonInfo::AS_CXX11, "clang::vecreturn" }, |
| 10303 | }; |
| 10304 | struct ParsedAttrInfoVecReturn final : public ParsedAttrInfo { |
| 10305 | ParsedAttrInfoVecReturn() { |
| 10306 | AttrKind = ParsedAttr::AT_VecReturn; |
| 10307 | NumArgs = 0; |
| 10308 | OptArgs = 0; |
| 10309 | HasCustomParsing = 0; |
| 10310 | IsTargetSpecific = 0; |
| 10311 | IsType = 0; |
| 10312 | IsStmt = 0; |
| 10313 | IsKnownToGCC = 0; |
| 10314 | IsSupportedByPragmaAttribute = 1; |
| 10315 | Spellings = VecReturnSpellings; |
| 10316 | } |
| 10317 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10318 | if (!isa<CXXRecordDecl>(D)) { |
| 10319 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 10320 | << Attr << "classes" ; |
| 10321 | return false; |
| 10322 | } |
| 10323 | return true; |
| 10324 | } |
| 10325 | |
| 10326 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10327 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 10328 | } |
| 10329 | |
| 10330 | static const ParsedAttrInfoVecReturn Instance; |
| 10331 | }; |
| 10332 | const ParsedAttrInfoVecReturn ParsedAttrInfoVecReturn::Instance; |
| 10333 | static constexpr ParsedAttrInfo::Spelling VecTypeHintSpellings[] = { |
| 10334 | {AttributeCommonInfo::AS_GNU, "vec_type_hint" }, |
| 10335 | }; |
| 10336 | struct ParsedAttrInfoVecTypeHint final : public ParsedAttrInfo { |
| 10337 | ParsedAttrInfoVecTypeHint() { |
| 10338 | AttrKind = ParsedAttr::AT_VecTypeHint; |
| 10339 | NumArgs = 1; |
| 10340 | OptArgs = 0; |
| 10341 | HasCustomParsing = 0; |
| 10342 | IsTargetSpecific = 0; |
| 10343 | IsType = 0; |
| 10344 | IsStmt = 0; |
| 10345 | IsKnownToGCC = 0; |
| 10346 | IsSupportedByPragmaAttribute = 1; |
| 10347 | Spellings = VecTypeHintSpellings; |
| 10348 | } |
| 10349 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10350 | if (!isa<FunctionDecl>(D)) { |
| 10351 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 10352 | << Attr << "functions" ; |
| 10353 | return false; |
| 10354 | } |
| 10355 | return true; |
| 10356 | } |
| 10357 | |
| 10358 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10359 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 10360 | } |
| 10361 | |
| 10362 | static const ParsedAttrInfoVecTypeHint Instance; |
| 10363 | }; |
| 10364 | const ParsedAttrInfoVecTypeHint ParsedAttrInfoVecTypeHint::Instance; |
| 10365 | static constexpr ParsedAttrInfo::Spelling VectorCallSpellings[] = { |
| 10366 | {AttributeCommonInfo::AS_GNU, "vectorcall" }, |
| 10367 | {AttributeCommonInfo::AS_CXX11, "clang::vectorcall" }, |
| 10368 | {AttributeCommonInfo::AS_C2x, "clang::vectorcall" }, |
| 10369 | {AttributeCommonInfo::AS_Keyword, "__vectorcall" }, |
| 10370 | {AttributeCommonInfo::AS_Keyword, "_vectorcall" }, |
| 10371 | }; |
| 10372 | struct ParsedAttrInfoVectorCall final : public ParsedAttrInfo { |
| 10373 | ParsedAttrInfoVectorCall() { |
| 10374 | AttrKind = ParsedAttr::AT_VectorCall; |
| 10375 | NumArgs = 0; |
| 10376 | OptArgs = 0; |
| 10377 | HasCustomParsing = 0; |
| 10378 | IsTargetSpecific = 0; |
| 10379 | IsType = 1; |
| 10380 | IsStmt = 0; |
| 10381 | IsKnownToGCC = 0; |
| 10382 | IsSupportedByPragmaAttribute = 0; |
| 10383 | Spellings = VectorCallSpellings; |
| 10384 | } |
| 10385 | static const ParsedAttrInfoVectorCall Instance; |
| 10386 | }; |
| 10387 | const ParsedAttrInfoVectorCall ParsedAttrInfoVectorCall::Instance; |
| 10388 | static constexpr ParsedAttrInfo::Spelling VectorSizeSpellings[] = { |
| 10389 | {AttributeCommonInfo::AS_GNU, "vector_size" }, |
| 10390 | {AttributeCommonInfo::AS_CXX11, "gnu::vector_size" }, |
| 10391 | {AttributeCommonInfo::AS_C2x, "gnu::vector_size" }, |
| 10392 | }; |
| 10393 | struct ParsedAttrInfoVectorSize final : public ParsedAttrInfo { |
| 10394 | ParsedAttrInfoVectorSize() { |
| 10395 | AttrKind = ParsedAttr::AT_VectorSize; |
| 10396 | NumArgs = 1; |
| 10397 | OptArgs = 0; |
| 10398 | HasCustomParsing = 0; |
| 10399 | IsTargetSpecific = 0; |
| 10400 | IsType = 1; |
| 10401 | IsStmt = 0; |
| 10402 | IsKnownToGCC = 1; |
| 10403 | IsSupportedByPragmaAttribute = 0; |
| 10404 | Spellings = VectorSizeSpellings; |
| 10405 | } |
| 10406 | static const ParsedAttrInfoVectorSize Instance; |
| 10407 | }; |
| 10408 | const ParsedAttrInfoVectorSize ParsedAttrInfoVectorSize::Instance; |
| 10409 | static constexpr ParsedAttrInfo::Spelling VisibilitySpellings[] = { |
| 10410 | {AttributeCommonInfo::AS_GNU, "visibility" }, |
| 10411 | {AttributeCommonInfo::AS_CXX11, "gnu::visibility" }, |
| 10412 | {AttributeCommonInfo::AS_C2x, "gnu::visibility" }, |
| 10413 | }; |
| 10414 | struct ParsedAttrInfoVisibility final : public ParsedAttrInfo { |
| 10415 | ParsedAttrInfoVisibility() { |
| 10416 | AttrKind = ParsedAttr::AT_Visibility; |
| 10417 | NumArgs = 1; |
| 10418 | OptArgs = 0; |
| 10419 | HasCustomParsing = 0; |
| 10420 | IsTargetSpecific = 0; |
| 10421 | IsType = 0; |
| 10422 | IsStmt = 0; |
| 10423 | IsKnownToGCC = 1; |
| 10424 | IsSupportedByPragmaAttribute = 0; |
| 10425 | Spellings = VisibilitySpellings; |
| 10426 | } |
| 10427 | static const ParsedAttrInfoVisibility Instance; |
| 10428 | }; |
| 10429 | const ParsedAttrInfoVisibility ParsedAttrInfoVisibility::Instance; |
| 10430 | static constexpr ParsedAttrInfo::Spelling WarnUnusedSpellings[] = { |
| 10431 | {AttributeCommonInfo::AS_GNU, "warn_unused" }, |
| 10432 | {AttributeCommonInfo::AS_CXX11, "gnu::warn_unused" }, |
| 10433 | {AttributeCommonInfo::AS_C2x, "gnu::warn_unused" }, |
| 10434 | }; |
| 10435 | struct ParsedAttrInfoWarnUnused final : public ParsedAttrInfo { |
| 10436 | ParsedAttrInfoWarnUnused() { |
| 10437 | AttrKind = ParsedAttr::AT_WarnUnused; |
| 10438 | NumArgs = 0; |
| 10439 | OptArgs = 0; |
| 10440 | HasCustomParsing = 0; |
| 10441 | IsTargetSpecific = 0; |
| 10442 | IsType = 0; |
| 10443 | IsStmt = 0; |
| 10444 | IsKnownToGCC = 1; |
| 10445 | IsSupportedByPragmaAttribute = 1; |
| 10446 | Spellings = WarnUnusedSpellings; |
| 10447 | } |
| 10448 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10449 | if (!isa<RecordDecl>(D)) { |
| 10450 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 10451 | << Attr << "structs, unions, and classes" ; |
| 10452 | return false; |
| 10453 | } |
| 10454 | return true; |
| 10455 | } |
| 10456 | |
| 10457 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10458 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 10459 | } |
| 10460 | |
| 10461 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 10462 | D->addAttr(::new (S.Context) WarnUnusedAttr(S.Context, Attr)); |
| 10463 | return AttributeApplied; |
| 10464 | } |
| 10465 | |
| 10466 | static const ParsedAttrInfoWarnUnused Instance; |
| 10467 | }; |
| 10468 | const ParsedAttrInfoWarnUnused ParsedAttrInfoWarnUnused::Instance; |
| 10469 | static constexpr ParsedAttrInfo::Spelling WarnUnusedResultSpellings[] = { |
| 10470 | {AttributeCommonInfo::AS_CXX11, "nodiscard" }, |
| 10471 | {AttributeCommonInfo::AS_C2x, "nodiscard" }, |
| 10472 | {AttributeCommonInfo::AS_CXX11, "clang::warn_unused_result" }, |
| 10473 | {AttributeCommonInfo::AS_GNU, "warn_unused_result" }, |
| 10474 | {AttributeCommonInfo::AS_CXX11, "gnu::warn_unused_result" }, |
| 10475 | {AttributeCommonInfo::AS_C2x, "gnu::warn_unused_result" }, |
| 10476 | }; |
| 10477 | struct ParsedAttrInfoWarnUnusedResult final : public ParsedAttrInfo { |
| 10478 | ParsedAttrInfoWarnUnusedResult() { |
| 10479 | AttrKind = ParsedAttr::AT_WarnUnusedResult; |
| 10480 | NumArgs = 0; |
| 10481 | OptArgs = 1; |
| 10482 | HasCustomParsing = 0; |
| 10483 | IsTargetSpecific = 0; |
| 10484 | IsType = 0; |
| 10485 | IsStmt = 0; |
| 10486 | IsKnownToGCC = 1; |
| 10487 | IsSupportedByPragmaAttribute = 1; |
| 10488 | Spellings = WarnUnusedResultSpellings; |
| 10489 | } |
| 10490 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10491 | if (!isa<ObjCMethodDecl>(D) && !isa<EnumDecl>(D) && !isa<RecordDecl>(D) && !isFunctionLike(D)) { |
| 10492 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 10493 | << Attr << "Objective-C methods, enums, structs, unions, classes, functions, and function pointers" ; |
| 10494 | return false; |
| 10495 | } |
| 10496 | return true; |
| 10497 | } |
| 10498 | |
| 10499 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 10500 | enum Spelling { |
| 10501 | CXX11_nodiscard = 0, |
| 10502 | C2x_nodiscard = 1, |
| 10503 | CXX11_clang_warn_unused_result = 2, |
| 10504 | GNU_warn_unused_result = 3, |
| 10505 | CXX11_gnu_warn_unused_result = 4, |
| 10506 | C2x_gnu_warn_unused_result = 5, |
| 10507 | SpellingNotCalculated = 15 |
| 10508 | |
| 10509 | }; |
| 10510 | |
| 10511 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 10512 | switch (Idx) { |
| 10513 | default: llvm_unreachable("Unknown spelling list index" ); |
| 10514 | case 0: return CXX11_nodiscard; |
| 10515 | case 1: return C2x_nodiscard; |
| 10516 | case 2: return CXX11_clang_warn_unused_result; |
| 10517 | case 3: return GNU_warn_unused_result; |
| 10518 | case 4: return CXX11_gnu_warn_unused_result; |
| 10519 | case 5: return C2x_gnu_warn_unused_result; |
| 10520 | } |
| 10521 | } |
| 10522 | |
| 10523 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10524 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 10525 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
| 10526 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 10527 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
| 10528 | } |
| 10529 | |
| 10530 | static const ParsedAttrInfoWarnUnusedResult Instance; |
| 10531 | }; |
| 10532 | const ParsedAttrInfoWarnUnusedResult ParsedAttrInfoWarnUnusedResult::Instance; |
| 10533 | static constexpr ParsedAttrInfo::Spelling WeakSpellings[] = { |
| 10534 | {AttributeCommonInfo::AS_GNU, "weak" }, |
| 10535 | {AttributeCommonInfo::AS_CXX11, "gnu::weak" }, |
| 10536 | {AttributeCommonInfo::AS_C2x, "gnu::weak" }, |
| 10537 | }; |
| 10538 | struct ParsedAttrInfoWeak final : public ParsedAttrInfo { |
| 10539 | ParsedAttrInfoWeak() { |
| 10540 | AttrKind = ParsedAttr::AT_Weak; |
| 10541 | NumArgs = 0; |
| 10542 | OptArgs = 0; |
| 10543 | HasCustomParsing = 0; |
| 10544 | IsTargetSpecific = 0; |
| 10545 | IsType = 0; |
| 10546 | IsStmt = 0; |
| 10547 | IsKnownToGCC = 1; |
| 10548 | IsSupportedByPragmaAttribute = 1; |
| 10549 | Spellings = WeakSpellings; |
| 10550 | } |
| 10551 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10552 | if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D)) { |
| 10553 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 10554 | << Attr << "variables, functions, and classes" ; |
| 10555 | return false; |
| 10556 | } |
| 10557 | return true; |
| 10558 | } |
| 10559 | |
| 10560 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10561 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 10562 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 10563 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
| 10564 | } |
| 10565 | |
| 10566 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 10567 | D->addAttr(::new (S.Context) WeakAttr(S.Context, Attr)); |
| 10568 | return AttributeApplied; |
| 10569 | } |
| 10570 | |
| 10571 | static const ParsedAttrInfoWeak Instance; |
| 10572 | }; |
| 10573 | const ParsedAttrInfoWeak ParsedAttrInfoWeak::Instance; |
| 10574 | static constexpr ParsedAttrInfo::Spelling WeakImportSpellings[] = { |
| 10575 | {AttributeCommonInfo::AS_GNU, "weak_import" }, |
| 10576 | {AttributeCommonInfo::AS_CXX11, "clang::weak_import" }, |
| 10577 | {AttributeCommonInfo::AS_C2x, "clang::weak_import" }, |
| 10578 | }; |
| 10579 | struct ParsedAttrInfoWeakImport final : public ParsedAttrInfo { |
| 10580 | ParsedAttrInfoWeakImport() { |
| 10581 | AttrKind = ParsedAttr::AT_WeakImport; |
| 10582 | NumArgs = 0; |
| 10583 | OptArgs = 0; |
| 10584 | HasCustomParsing = 0; |
| 10585 | IsTargetSpecific = 0; |
| 10586 | IsType = 0; |
| 10587 | IsStmt = 0; |
| 10588 | IsKnownToGCC = 0; |
| 10589 | IsSupportedByPragmaAttribute = 0; |
| 10590 | Spellings = WeakImportSpellings; |
| 10591 | } |
| 10592 | static const ParsedAttrInfoWeakImport Instance; |
| 10593 | }; |
| 10594 | const ParsedAttrInfoWeakImport ParsedAttrInfoWeakImport::Instance; |
| 10595 | static constexpr ParsedAttrInfo::Spelling WeakRefSpellings[] = { |
| 10596 | {AttributeCommonInfo::AS_GNU, "weakref" }, |
| 10597 | {AttributeCommonInfo::AS_CXX11, "gnu::weakref" }, |
| 10598 | {AttributeCommonInfo::AS_C2x, "gnu::weakref" }, |
| 10599 | }; |
| 10600 | struct ParsedAttrInfoWeakRef final : public ParsedAttrInfo { |
| 10601 | ParsedAttrInfoWeakRef() { |
| 10602 | AttrKind = ParsedAttr::AT_WeakRef; |
| 10603 | NumArgs = 0; |
| 10604 | OptArgs = 1; |
| 10605 | HasCustomParsing = 0; |
| 10606 | IsTargetSpecific = 0; |
| 10607 | IsType = 0; |
| 10608 | IsStmt = 0; |
| 10609 | IsKnownToGCC = 1; |
| 10610 | IsSupportedByPragmaAttribute = 1; |
| 10611 | Spellings = WeakRefSpellings; |
| 10612 | } |
| 10613 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10614 | if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D)) { |
| 10615 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 10616 | << Attr << "variables and functions" ; |
| 10617 | return false; |
| 10618 | } |
| 10619 | return true; |
| 10620 | } |
| 10621 | |
| 10622 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10623 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
| 10624 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 10625 | } |
| 10626 | |
| 10627 | static const ParsedAttrInfoWeakRef Instance; |
| 10628 | }; |
| 10629 | const ParsedAttrInfoWeakRef ParsedAttrInfoWeakRef::Instance; |
| 10630 | static constexpr ParsedAttrInfo::Spelling WebAssemblyExportNameSpellings[] = { |
| 10631 | {AttributeCommonInfo::AS_GNU, "export_name" }, |
| 10632 | {AttributeCommonInfo::AS_CXX11, "clang::export_name" }, |
| 10633 | {AttributeCommonInfo::AS_C2x, "clang::export_name" }, |
| 10634 | }; |
| 10635 | struct ParsedAttrInfoWebAssemblyExportName final : public ParsedAttrInfo { |
| 10636 | ParsedAttrInfoWebAssemblyExportName() { |
| 10637 | AttrKind = ParsedAttr::AT_WebAssemblyExportName; |
| 10638 | NumArgs = 1; |
| 10639 | OptArgs = 0; |
| 10640 | HasCustomParsing = 0; |
| 10641 | IsTargetSpecific = 1; |
| 10642 | IsType = 0; |
| 10643 | IsStmt = 0; |
| 10644 | IsKnownToGCC = 0; |
| 10645 | IsSupportedByPragmaAttribute = 1; |
| 10646 | Spellings = WebAssemblyExportNameSpellings; |
| 10647 | } |
| 10648 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10649 | if (!isa<FunctionDecl>(D)) { |
| 10650 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 10651 | << Attr << "functions" ; |
| 10652 | return false; |
| 10653 | } |
| 10654 | return true; |
| 10655 | } |
| 10656 | |
| 10657 | bool existsInTarget(const TargetInfo &Target) const override { |
| 10658 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 10659 | return true && (T.getArch() == llvm::Triple::wasm32 || T.getArch() == llvm::Triple::wasm64); |
| 10660 | } |
| 10661 | |
| 10662 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10663 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 10664 | } |
| 10665 | |
| 10666 | static const ParsedAttrInfoWebAssemblyExportName Instance; |
| 10667 | }; |
| 10668 | const ParsedAttrInfoWebAssemblyExportName ParsedAttrInfoWebAssemblyExportName::Instance; |
| 10669 | static constexpr ParsedAttrInfo::Spelling WebAssemblyImportModuleSpellings[] = { |
| 10670 | {AttributeCommonInfo::AS_GNU, "import_module" }, |
| 10671 | {AttributeCommonInfo::AS_CXX11, "clang::import_module" }, |
| 10672 | {AttributeCommonInfo::AS_C2x, "clang::import_module" }, |
| 10673 | }; |
| 10674 | struct ParsedAttrInfoWebAssemblyImportModule final : public ParsedAttrInfo { |
| 10675 | ParsedAttrInfoWebAssemblyImportModule() { |
| 10676 | AttrKind = ParsedAttr::AT_WebAssemblyImportModule; |
| 10677 | NumArgs = 1; |
| 10678 | OptArgs = 0; |
| 10679 | HasCustomParsing = 0; |
| 10680 | IsTargetSpecific = 1; |
| 10681 | IsType = 0; |
| 10682 | IsStmt = 0; |
| 10683 | IsKnownToGCC = 0; |
| 10684 | IsSupportedByPragmaAttribute = 1; |
| 10685 | Spellings = WebAssemblyImportModuleSpellings; |
| 10686 | } |
| 10687 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10688 | if (!isa<FunctionDecl>(D)) { |
| 10689 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 10690 | << Attr << "functions" ; |
| 10691 | return false; |
| 10692 | } |
| 10693 | return true; |
| 10694 | } |
| 10695 | |
| 10696 | bool existsInTarget(const TargetInfo &Target) const override { |
| 10697 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 10698 | return true && (T.getArch() == llvm::Triple::wasm32 || T.getArch() == llvm::Triple::wasm64); |
| 10699 | } |
| 10700 | |
| 10701 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10702 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 10703 | } |
| 10704 | |
| 10705 | static const ParsedAttrInfoWebAssemblyImportModule Instance; |
| 10706 | }; |
| 10707 | const ParsedAttrInfoWebAssemblyImportModule ParsedAttrInfoWebAssemblyImportModule::Instance; |
| 10708 | static constexpr ParsedAttrInfo::Spelling WebAssemblyImportNameSpellings[] = { |
| 10709 | {AttributeCommonInfo::AS_GNU, "import_name" }, |
| 10710 | {AttributeCommonInfo::AS_CXX11, "clang::import_name" }, |
| 10711 | {AttributeCommonInfo::AS_C2x, "clang::import_name" }, |
| 10712 | }; |
| 10713 | struct ParsedAttrInfoWebAssemblyImportName final : public ParsedAttrInfo { |
| 10714 | ParsedAttrInfoWebAssemblyImportName() { |
| 10715 | AttrKind = ParsedAttr::AT_WebAssemblyImportName; |
| 10716 | NumArgs = 1; |
| 10717 | OptArgs = 0; |
| 10718 | HasCustomParsing = 0; |
| 10719 | IsTargetSpecific = 1; |
| 10720 | IsType = 0; |
| 10721 | IsStmt = 0; |
| 10722 | IsKnownToGCC = 0; |
| 10723 | IsSupportedByPragmaAttribute = 1; |
| 10724 | Spellings = WebAssemblyImportNameSpellings; |
| 10725 | } |
| 10726 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10727 | if (!isa<FunctionDecl>(D)) { |
| 10728 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 10729 | << Attr << "functions" ; |
| 10730 | return false; |
| 10731 | } |
| 10732 | return true; |
| 10733 | } |
| 10734 | |
| 10735 | bool existsInTarget(const TargetInfo &Target) const override { |
| 10736 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 10737 | return true && (T.getArch() == llvm::Triple::wasm32 || T.getArch() == llvm::Triple::wasm64); |
| 10738 | } |
| 10739 | |
| 10740 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10741 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 10742 | } |
| 10743 | |
| 10744 | static const ParsedAttrInfoWebAssemblyImportName Instance; |
| 10745 | }; |
| 10746 | const ParsedAttrInfoWebAssemblyImportName ParsedAttrInfoWebAssemblyImportName::Instance; |
| 10747 | static constexpr ParsedAttrInfo::Spelling WorkGroupSizeHintSpellings[] = { |
| 10748 | {AttributeCommonInfo::AS_GNU, "work_group_size_hint" }, |
| 10749 | }; |
| 10750 | struct ParsedAttrInfoWorkGroupSizeHint final : public ParsedAttrInfo { |
| 10751 | ParsedAttrInfoWorkGroupSizeHint() { |
| 10752 | AttrKind = ParsedAttr::AT_WorkGroupSizeHint; |
| 10753 | NumArgs = 3; |
| 10754 | OptArgs = 0; |
| 10755 | HasCustomParsing = 0; |
| 10756 | IsTargetSpecific = 0; |
| 10757 | IsType = 0; |
| 10758 | IsStmt = 0; |
| 10759 | IsKnownToGCC = 0; |
| 10760 | IsSupportedByPragmaAttribute = 1; |
| 10761 | Spellings = WorkGroupSizeHintSpellings; |
| 10762 | } |
| 10763 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10764 | if (!isa<FunctionDecl>(D)) { |
| 10765 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
| 10766 | << Attr << "functions" ; |
| 10767 | return false; |
| 10768 | } |
| 10769 | return true; |
| 10770 | } |
| 10771 | |
| 10772 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10773 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 10774 | } |
| 10775 | |
| 10776 | static const ParsedAttrInfoWorkGroupSizeHint Instance; |
| 10777 | }; |
| 10778 | const ParsedAttrInfoWorkGroupSizeHint ParsedAttrInfoWorkGroupSizeHint::Instance; |
| 10779 | static constexpr ParsedAttrInfo::Spelling X86ForceAlignArgPointerSpellings[] = { |
| 10780 | {AttributeCommonInfo::AS_GNU, "force_align_arg_pointer" }, |
| 10781 | {AttributeCommonInfo::AS_CXX11, "gnu::force_align_arg_pointer" }, |
| 10782 | {AttributeCommonInfo::AS_C2x, "gnu::force_align_arg_pointer" }, |
| 10783 | }; |
| 10784 | struct ParsedAttrInfoX86ForceAlignArgPointer final : public ParsedAttrInfo { |
| 10785 | ParsedAttrInfoX86ForceAlignArgPointer() { |
| 10786 | AttrKind = ParsedAttr::AT_X86ForceAlignArgPointer; |
| 10787 | NumArgs = 0; |
| 10788 | OptArgs = 0; |
| 10789 | HasCustomParsing = 0; |
| 10790 | IsTargetSpecific = 1; |
| 10791 | IsType = 0; |
| 10792 | IsStmt = 0; |
| 10793 | IsKnownToGCC = 1; |
| 10794 | IsSupportedByPragmaAttribute = 0; |
| 10795 | Spellings = X86ForceAlignArgPointerSpellings; |
| 10796 | } |
| 10797 | bool existsInTarget(const TargetInfo &Target) const override { |
| 10798 | const llvm::Triple &T = Target.getTriple(); (void)T; |
| 10799 | return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64); |
| 10800 | } |
| 10801 | |
| 10802 | static const ParsedAttrInfoX86ForceAlignArgPointer Instance; |
| 10803 | }; |
| 10804 | const ParsedAttrInfoX86ForceAlignArgPointer ParsedAttrInfoX86ForceAlignArgPointer::Instance; |
| 10805 | static constexpr ParsedAttrInfo::Spelling XRayInstrumentSpellings[] = { |
| 10806 | {AttributeCommonInfo::AS_GNU, "xray_always_instrument" }, |
| 10807 | {AttributeCommonInfo::AS_CXX11, "clang::xray_always_instrument" }, |
| 10808 | {AttributeCommonInfo::AS_C2x, "clang::xray_always_instrument" }, |
| 10809 | {AttributeCommonInfo::AS_GNU, "xray_never_instrument" }, |
| 10810 | {AttributeCommonInfo::AS_CXX11, "clang::xray_never_instrument" }, |
| 10811 | {AttributeCommonInfo::AS_C2x, "clang::xray_never_instrument" }, |
| 10812 | }; |
| 10813 | struct ParsedAttrInfoXRayInstrument final : public ParsedAttrInfo { |
| 10814 | ParsedAttrInfoXRayInstrument() { |
| 10815 | AttrKind = ParsedAttr::AT_XRayInstrument; |
| 10816 | NumArgs = 0; |
| 10817 | OptArgs = 0; |
| 10818 | HasCustomParsing = 0; |
| 10819 | IsTargetSpecific = 0; |
| 10820 | IsType = 0; |
| 10821 | IsStmt = 0; |
| 10822 | IsKnownToGCC = 0; |
| 10823 | IsSupportedByPragmaAttribute = 1; |
| 10824 | Spellings = XRayInstrumentSpellings; |
| 10825 | } |
| 10826 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10827 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 10828 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 10829 | << Attr << "functions and Objective-C methods" ; |
| 10830 | return false; |
| 10831 | } |
| 10832 | return true; |
| 10833 | } |
| 10834 | |
| 10835 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
| 10836 | enum Spelling { |
| 10837 | GNU_xray_always_instrument = 0, |
| 10838 | CXX11_clang_xray_always_instrument = 1, |
| 10839 | C2x_clang_xray_always_instrument = 2, |
| 10840 | GNU_xray_never_instrument = 3, |
| 10841 | CXX11_clang_xray_never_instrument = 4, |
| 10842 | C2x_clang_xray_never_instrument = 5, |
| 10843 | SpellingNotCalculated = 15 |
| 10844 | |
| 10845 | }; |
| 10846 | |
| 10847 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
| 10848 | switch (Idx) { |
| 10849 | default: llvm_unreachable("Unknown spelling list index" ); |
| 10850 | case 0: return GNU_xray_always_instrument; |
| 10851 | case 1: return CXX11_clang_xray_always_instrument; |
| 10852 | case 2: return C2x_clang_xray_always_instrument; |
| 10853 | case 3: return GNU_xray_never_instrument; |
| 10854 | case 4: return CXX11_clang_xray_never_instrument; |
| 10855 | case 5: return C2x_clang_xray_never_instrument; |
| 10856 | } |
| 10857 | } |
| 10858 | |
| 10859 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10860 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 10861 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 10862 | } |
| 10863 | |
| 10864 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
| 10865 | D->addAttr(::new (S.Context) XRayInstrumentAttr(S.Context, Attr)); |
| 10866 | return AttributeApplied; |
| 10867 | } |
| 10868 | |
| 10869 | static const ParsedAttrInfoXRayInstrument Instance; |
| 10870 | }; |
| 10871 | const ParsedAttrInfoXRayInstrument ParsedAttrInfoXRayInstrument::Instance; |
| 10872 | static constexpr ParsedAttrInfo::Spelling XRayLogArgsSpellings[] = { |
| 10873 | {AttributeCommonInfo::AS_GNU, "xray_log_args" }, |
| 10874 | {AttributeCommonInfo::AS_CXX11, "clang::xray_log_args" }, |
| 10875 | {AttributeCommonInfo::AS_C2x, "clang::xray_log_args" }, |
| 10876 | }; |
| 10877 | struct ParsedAttrInfoXRayLogArgs final : public ParsedAttrInfo { |
| 10878 | ParsedAttrInfoXRayLogArgs() { |
| 10879 | AttrKind = ParsedAttr::AT_XRayLogArgs; |
| 10880 | NumArgs = 1; |
| 10881 | OptArgs = 0; |
| 10882 | HasCustomParsing = 0; |
| 10883 | IsTargetSpecific = 0; |
| 10884 | IsType = 0; |
| 10885 | IsStmt = 0; |
| 10886 | IsKnownToGCC = 0; |
| 10887 | IsSupportedByPragmaAttribute = 1; |
| 10888 | Spellings = XRayLogArgsSpellings; |
| 10889 | } |
| 10890 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
| 10891 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
| 10892 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
| 10893 | << Attr << "functions and Objective-C methods" ; |
| 10894 | return false; |
| 10895 | } |
| 10896 | return true; |
| 10897 | } |
| 10898 | |
| 10899 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
| 10900 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
| 10901 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
| 10902 | } |
| 10903 | |
| 10904 | static const ParsedAttrInfoXRayLogArgs Instance; |
| 10905 | }; |
| 10906 | const ParsedAttrInfoXRayLogArgs ParsedAttrInfoXRayLogArgs::Instance; |
| 10907 | static const ParsedAttrInfo *AttrInfoMap[] = { |
| 10908 | &ParsedAttrInfoAArch64VectorPcs::Instance, |
| 10909 | &ParsedAttrInfoAMDGPUFlatWorkGroupSize::Instance, |
| 10910 | &ParsedAttrInfoAMDGPUNumSGPR::Instance, |
| 10911 | &ParsedAttrInfoAMDGPUNumVGPR::Instance, |
| 10912 | &ParsedAttrInfoAMDGPUWavesPerEU::Instance, |
| 10913 | &ParsedAttrInfoInterrupt::Instance, |
| 10914 | &ParsedAttrInfoAVRSignal::Instance, |
| 10915 | &ParsedAttrInfoAbiTag::Instance, |
| 10916 | &ParsedAttrInfoAcquireCapability::Instance, |
| 10917 | &ParsedAttrInfoAcquireHandle::Instance, |
| 10918 | &ParsedAttrInfoAcquiredAfter::Instance, |
| 10919 | &ParsedAttrInfoAcquiredBefore::Instance, |
| 10920 | &ParsedAttrInfoAddressSpace::Instance, |
| 10921 | &ParsedAttrInfoAlias::Instance, |
| 10922 | &ParsedAttrInfoAlignValue::Instance, |
| 10923 | &ParsedAttrInfoAligned::Instance, |
| 10924 | &ParsedAttrInfoAllocAlign::Instance, |
| 10925 | &ParsedAttrInfoAllocSize::Instance, |
| 10926 | &ParsedAttrInfoAlwaysDestroy::Instance, |
| 10927 | &ParsedAttrInfoAlwaysInline::Instance, |
| 10928 | &ParsedAttrInfoAnalyzerNoReturn::Instance, |
| 10929 | &ParsedAttrInfoAnnotate::Instance, |
| 10930 | &ParsedAttrInfoAnyX86NoCallerSavedRegisters::Instance, |
| 10931 | &ParsedAttrInfoAnyX86NoCfCheck::Instance, |
| 10932 | &ParsedAttrInfoArcWeakrefUnavailable::Instance, |
| 10933 | &ParsedAttrInfoArgumentWithTypeTag::Instance, |
| 10934 | &ParsedAttrInfoArmBuiltinAlias::Instance, |
| 10935 | &ParsedAttrInfoArmMveStrictPolymorphism::Instance, |
| 10936 | &ParsedAttrInfoArmSveVectorBits::Instance, |
| 10937 | &ParsedAttrInfoArtificial::Instance, |
| 10938 | &ParsedAttrInfoAssertCapability::Instance, |
| 10939 | &ParsedAttrInfoAssertExclusiveLock::Instance, |
| 10940 | &ParsedAttrInfoAssertSharedLock::Instance, |
| 10941 | &ParsedAttrInfoAssumeAligned::Instance, |
| 10942 | &ParsedAttrInfoAssumption::Instance, |
| 10943 | &ParsedAttrInfoAvailability::Instance, |
| 10944 | &ParsedAttrInfoBPFPreserveAccessIndex::Instance, |
| 10945 | &ParsedAttrInfoBlocks::Instance, |
| 10946 | &ParsedAttrInfoCDecl::Instance, |
| 10947 | &ParsedAttrInfoCFAuditedTransfer::Instance, |
| 10948 | &ParsedAttrInfoCFConsumed::Instance, |
| 10949 | &ParsedAttrInfoCFGuard::Instance, |
| 10950 | &ParsedAttrInfoCFICanonicalJumpTable::Instance, |
| 10951 | &ParsedAttrInfoCFReturnsNotRetained::Instance, |
| 10952 | &ParsedAttrInfoCFReturnsRetained::Instance, |
| 10953 | &ParsedAttrInfoCFUnknownTransfer::Instance, |
| 10954 | &ParsedAttrInfoCPUDispatch::Instance, |
| 10955 | &ParsedAttrInfoCPUSpecific::Instance, |
| 10956 | &ParsedAttrInfoCUDAConstant::Instance, |
| 10957 | &ParsedAttrInfoCUDADevice::Instance, |
| 10958 | &ParsedAttrInfoCUDADeviceBuiltinSurfaceType::Instance, |
| 10959 | &ParsedAttrInfoCUDADeviceBuiltinTextureType::Instance, |
| 10960 | &ParsedAttrInfoCUDAGlobal::Instance, |
| 10961 | &ParsedAttrInfoCUDAHost::Instance, |
| 10962 | &ParsedAttrInfoCUDAInvalidTarget::Instance, |
| 10963 | &ParsedAttrInfoCUDALaunchBounds::Instance, |
| 10964 | &ParsedAttrInfoCUDAShared::Instance, |
| 10965 | &ParsedAttrInfoCXX11NoReturn::Instance, |
| 10966 | &ParsedAttrInfoCallableWhen::Instance, |
| 10967 | &ParsedAttrInfoCallback::Instance, |
| 10968 | &ParsedAttrInfoCalledOnce::Instance, |
| 10969 | &ParsedAttrInfoCapability::Instance, |
| 10970 | &ParsedAttrInfoCarriesDependency::Instance, |
| 10971 | &ParsedAttrInfoCleanup::Instance, |
| 10972 | &ParsedAttrInfoCmseNSCall::Instance, |
| 10973 | &ParsedAttrInfoCmseNSEntry::Instance, |
| 10974 | &ParsedAttrInfoCodeSeg::Instance, |
| 10975 | &ParsedAttrInfoCold::Instance, |
| 10976 | &ParsedAttrInfoCommon::Instance, |
| 10977 | &ParsedAttrInfoConst::Instance, |
| 10978 | &ParsedAttrInfoConstInit::Instance, |
| 10979 | &ParsedAttrInfoConstructor::Instance, |
| 10980 | &ParsedAttrInfoConsumable::Instance, |
| 10981 | &ParsedAttrInfoConsumableAutoCast::Instance, |
| 10982 | &ParsedAttrInfoConsumableSetOnRead::Instance, |
| 10983 | &ParsedAttrInfoConvergent::Instance, |
| 10984 | &ParsedAttrInfoDLLExport::Instance, |
| 10985 | &ParsedAttrInfoDLLExportStaticLocal::Instance, |
| 10986 | &ParsedAttrInfoDLLImport::Instance, |
| 10987 | &ParsedAttrInfoDLLImportStaticLocal::Instance, |
| 10988 | &ParsedAttrInfoDeprecated::Instance, |
| 10989 | &ParsedAttrInfoDestructor::Instance, |
| 10990 | &ParsedAttrInfoDiagnoseIf::Instance, |
| 10991 | &ParsedAttrInfoDisableTailCalls::Instance, |
| 10992 | &ParsedAttrInfoEmptyBases::Instance, |
| 10993 | &ParsedAttrInfoEnableIf::Instance, |
| 10994 | &ParsedAttrInfoEnforceTCB::Instance, |
| 10995 | &ParsedAttrInfoEnforceTCBLeaf::Instance, |
| 10996 | &ParsedAttrInfoEnumExtensibility::Instance, |
| 10997 | &ParsedAttrInfoExcludeFromExplicitInstantiation::Instance, |
| 10998 | &ParsedAttrInfoExclusiveTrylockFunction::Instance, |
| 10999 | &ParsedAttrInfoExtVectorType::Instance, |
| 11000 | &ParsedAttrInfoExternalSourceSymbol::Instance, |
| 11001 | &ParsedAttrInfoFallThrough::Instance, |
| 11002 | &ParsedAttrInfoFastCall::Instance, |
| 11003 | &ParsedAttrInfoFlagEnum::Instance, |
| 11004 | &ParsedAttrInfoFlatten::Instance, |
| 11005 | &ParsedAttrInfoFormat::Instance, |
| 11006 | &ParsedAttrInfoFormatArg::Instance, |
| 11007 | &ParsedAttrInfoGNUInline::Instance, |
| 11008 | &ParsedAttrInfoGuardedBy::Instance, |
| 11009 | &ParsedAttrInfoGuardedVar::Instance, |
| 11010 | &ParsedAttrInfoHIPManaged::Instance, |
| 11011 | &ParsedAttrInfoHot::Instance, |
| 11012 | &ParsedAttrInfoIBAction::Instance, |
| 11013 | &ParsedAttrInfoIBOutlet::Instance, |
| 11014 | &ParsedAttrInfoIBOutletCollection::Instance, |
| 11015 | &ParsedAttrInfoIFunc::Instance, |
| 11016 | &ParsedAttrInfoInitPriority::Instance, |
| 11017 | &ParsedAttrInfoIntelOclBicc::Instance, |
| 11018 | &ParsedAttrInfoInternalLinkage::Instance, |
| 11019 | &ParsedAttrInfoLTOVisibilityPublic::Instance, |
| 11020 | &ParsedAttrInfoLayoutVersion::Instance, |
| 11021 | &ParsedAttrInfoLeaf::Instance, |
| 11022 | &ParsedAttrInfoLifetimeBound::Instance, |
| 11023 | &ParsedAttrInfoLikely::Instance, |
| 11024 | &ParsedAttrInfoLoaderUninitialized::Instance, |
| 11025 | &ParsedAttrInfoLockReturned::Instance, |
| 11026 | &ParsedAttrInfoLockable::Instance, |
| 11027 | &ParsedAttrInfoLocksExcluded::Instance, |
| 11028 | &ParsedAttrInfoLoopHint::Instance, |
| 11029 | &ParsedAttrInfoMIGServerRoutine::Instance, |
| 11030 | &ParsedAttrInfoMSABI::Instance, |
| 11031 | &ParsedAttrInfoMSAllocator::Instance, |
| 11032 | &ParsedAttrInfoMSInheritance::Instance, |
| 11033 | &ParsedAttrInfoMSNoVTable::Instance, |
| 11034 | &ParsedAttrInfoMSStruct::Instance, |
| 11035 | &ParsedAttrInfoMatrixType::Instance, |
| 11036 | &ParsedAttrInfoMayAlias::Instance, |
| 11037 | &ParsedAttrInfoMicroMips::Instance, |
| 11038 | &ParsedAttrInfoMinSize::Instance, |
| 11039 | &ParsedAttrInfoMinVectorWidth::Instance, |
| 11040 | &ParsedAttrInfoMips16::Instance, |
| 11041 | &ParsedAttrInfoMipsLongCall::Instance, |
| 11042 | &ParsedAttrInfoMipsShortCall::Instance, |
| 11043 | &ParsedAttrInfoMode::Instance, |
| 11044 | &ParsedAttrInfoNSConsumed::Instance, |
| 11045 | &ParsedAttrInfoNSConsumesSelf::Instance, |
| 11046 | &ParsedAttrInfoNSErrorDomain::Instance, |
| 11047 | &ParsedAttrInfoNSReturnsAutoreleased::Instance, |
| 11048 | &ParsedAttrInfoNSReturnsNotRetained::Instance, |
| 11049 | &ParsedAttrInfoNSReturnsRetained::Instance, |
| 11050 | &ParsedAttrInfoNaked::Instance, |
| 11051 | &ParsedAttrInfoNeonPolyVectorType::Instance, |
| 11052 | &ParsedAttrInfoNeonVectorType::Instance, |
| 11053 | &ParsedAttrInfoNoAlias::Instance, |
| 11054 | &ParsedAttrInfoNoBuiltin::Instance, |
| 11055 | &ParsedAttrInfoNoCommon::Instance, |
| 11056 | &ParsedAttrInfoNoDebug::Instance, |
| 11057 | &ParsedAttrInfoNoDeref::Instance, |
| 11058 | &ParsedAttrInfoNoDestroy::Instance, |
| 11059 | &ParsedAttrInfoNoDuplicate::Instance, |
| 11060 | &ParsedAttrInfoNoEscape::Instance, |
| 11061 | &ParsedAttrInfoNoInline::Instance, |
| 11062 | &ParsedAttrInfoNoInstrumentFunction::Instance, |
| 11063 | &ParsedAttrInfoNoMerge::Instance, |
| 11064 | &ParsedAttrInfoNoMicroMips::Instance, |
| 11065 | &ParsedAttrInfoNoMips16::Instance, |
| 11066 | &ParsedAttrInfoNoReturn::Instance, |
| 11067 | &ParsedAttrInfoNoSanitize::Instance, |
| 11068 | &ParsedAttrInfoNoSanitizeSpecific::Instance, |
| 11069 | &ParsedAttrInfoNoSpeculativeLoadHardening::Instance, |
| 11070 | &ParsedAttrInfoNoSplitStack::Instance, |
| 11071 | &ParsedAttrInfoNoStackProtector::Instance, |
| 11072 | &ParsedAttrInfoNoThreadSafetyAnalysis::Instance, |
| 11073 | &ParsedAttrInfoNoThrow::Instance, |
| 11074 | &ParsedAttrInfoNoUniqueAddress::Instance, |
| 11075 | &ParsedAttrInfoNonNull::Instance, |
| 11076 | &ParsedAttrInfoNotTailCalled::Instance, |
| 11077 | &ParsedAttrInfoOSConsumed::Instance, |
| 11078 | &ParsedAttrInfoOSConsumesThis::Instance, |
| 11079 | &ParsedAttrInfoOSReturnsNotRetained::Instance, |
| 11080 | &ParsedAttrInfoOSReturnsRetained::Instance, |
| 11081 | &ParsedAttrInfoOSReturnsRetainedOnNonZero::Instance, |
| 11082 | &ParsedAttrInfoOSReturnsRetainedOnZero::Instance, |
| 11083 | &ParsedAttrInfoObjCBoxable::Instance, |
| 11084 | &ParsedAttrInfoObjCBridge::Instance, |
| 11085 | &ParsedAttrInfoObjCBridgeMutable::Instance, |
| 11086 | &ParsedAttrInfoObjCBridgeRelated::Instance, |
| 11087 | &ParsedAttrInfoObjCClassStub::Instance, |
| 11088 | &ParsedAttrInfoObjCDesignatedInitializer::Instance, |
| 11089 | &ParsedAttrInfoObjCDirect::Instance, |
| 11090 | &ParsedAttrInfoObjCDirectMembers::Instance, |
| 11091 | &ParsedAttrInfoObjCException::Instance, |
| 11092 | &ParsedAttrInfoObjCExplicitProtocolImpl::Instance, |
| 11093 | &ParsedAttrInfoObjCExternallyRetained::Instance, |
| 11094 | &ParsedAttrInfoObjCGC::Instance, |
| 11095 | &ParsedAttrInfoObjCIndependentClass::Instance, |
| 11096 | &ParsedAttrInfoObjCInertUnsafeUnretained::Instance, |
| 11097 | &ParsedAttrInfoObjCKindOf::Instance, |
| 11098 | &ParsedAttrInfoObjCMethodFamily::Instance, |
| 11099 | &ParsedAttrInfoObjCNSObject::Instance, |
| 11100 | &ParsedAttrInfoObjCNonLazyClass::Instance, |
| 11101 | &ParsedAttrInfoObjCNonRuntimeProtocol::Instance, |
| 11102 | &ParsedAttrInfoObjCOwnership::Instance, |
| 11103 | &ParsedAttrInfoObjCPreciseLifetime::Instance, |
| 11104 | &ParsedAttrInfoObjCRequiresPropertyDefs::Instance, |
| 11105 | &ParsedAttrInfoObjCRequiresSuper::Instance, |
| 11106 | &ParsedAttrInfoObjCReturnsInnerPointer::Instance, |
| 11107 | &ParsedAttrInfoObjCRootClass::Instance, |
| 11108 | &ParsedAttrInfoObjCRuntimeName::Instance, |
| 11109 | &ParsedAttrInfoObjCRuntimeVisible::Instance, |
| 11110 | &ParsedAttrInfoObjCSubclassingRestricted::Instance, |
| 11111 | &ParsedAttrInfoOpenCLAccess::Instance, |
| 11112 | &ParsedAttrInfoOpenCLConstantAddressSpace::Instance, |
| 11113 | &ParsedAttrInfoOpenCLGenericAddressSpace::Instance, |
| 11114 | &ParsedAttrInfoOpenCLGlobalAddressSpace::Instance, |
| 11115 | &ParsedAttrInfoOpenCLGlobalDeviceAddressSpace::Instance, |
| 11116 | &ParsedAttrInfoOpenCLGlobalHostAddressSpace::Instance, |
| 11117 | &ParsedAttrInfoOpenCLIntelReqdSubGroupSize::Instance, |
| 11118 | &ParsedAttrInfoOpenCLKernel::Instance, |
| 11119 | &ParsedAttrInfoOpenCLLocalAddressSpace::Instance, |
| 11120 | &ParsedAttrInfoOpenCLNoSVM::Instance, |
| 11121 | &ParsedAttrInfoOpenCLPrivateAddressSpace::Instance, |
| 11122 | &ParsedAttrInfoOpenCLUnrollHint::Instance, |
| 11123 | &ParsedAttrInfoOptimizeNone::Instance, |
| 11124 | &ParsedAttrInfoOverloadable::Instance, |
| 11125 | &ParsedAttrInfoOwner::Instance, |
| 11126 | &ParsedAttrInfoOwnership::Instance, |
| 11127 | &ParsedAttrInfoPacked::Instance, |
| 11128 | &ParsedAttrInfoParamTypestate::Instance, |
| 11129 | &ParsedAttrInfoPascal::Instance, |
| 11130 | &ParsedAttrInfoPassObjectSize::Instance, |
| 11131 | &ParsedAttrInfoPatchableFunctionEntry::Instance, |
| 11132 | &ParsedAttrInfoPcs::Instance, |
| 11133 | &ParsedAttrInfoPointer::Instance, |
| 11134 | &ParsedAttrInfoPragmaClangBSSSection::Instance, |
| 11135 | &ParsedAttrInfoPragmaClangDataSection::Instance, |
| 11136 | &ParsedAttrInfoPragmaClangRelroSection::Instance, |
| 11137 | &ParsedAttrInfoPragmaClangRodataSection::Instance, |
| 11138 | &ParsedAttrInfoPragmaClangTextSection::Instance, |
| 11139 | &ParsedAttrInfoPreferredName::Instance, |
| 11140 | &ParsedAttrInfoPreserveAll::Instance, |
| 11141 | &ParsedAttrInfoPreserveMost::Instance, |
| 11142 | &ParsedAttrInfoPtGuardedBy::Instance, |
| 11143 | &ParsedAttrInfoPtGuardedVar::Instance, |
| 11144 | &ParsedAttrInfoPtr32::Instance, |
| 11145 | &ParsedAttrInfoPtr64::Instance, |
| 11146 | &ParsedAttrInfoPure::Instance, |
| 11147 | &ParsedAttrInfoRegCall::Instance, |
| 11148 | &ParsedAttrInfoRegparm::Instance, |
| 11149 | &ParsedAttrInfoReinitializes::Instance, |
| 11150 | &ParsedAttrInfoReleaseCapability::Instance, |
| 11151 | &ParsedAttrInfoReleaseHandle::Instance, |
| 11152 | &ParsedAttrInfoRenderScriptKernel::Instance, |
| 11153 | &ParsedAttrInfoReqdWorkGroupSize::Instance, |
| 11154 | &ParsedAttrInfoRequiresCapability::Instance, |
| 11155 | &ParsedAttrInfoRestrict::Instance, |
| 11156 | &ParsedAttrInfoReturnTypestate::Instance, |
| 11157 | &ParsedAttrInfoReturnsNonNull::Instance, |
| 11158 | &ParsedAttrInfoReturnsTwice::Instance, |
| 11159 | &ParsedAttrInfoSPtr::Instance, |
| 11160 | &ParsedAttrInfoSYCLKernel::Instance, |
| 11161 | &ParsedAttrInfoScopedLockable::Instance, |
| 11162 | &ParsedAttrInfoSection::Instance, |
| 11163 | &ParsedAttrInfoSelectAny::Instance, |
| 11164 | &ParsedAttrInfoSentinel::Instance, |
| 11165 | &ParsedAttrInfoSetTypestate::Instance, |
| 11166 | &ParsedAttrInfoSharedTrylockFunction::Instance, |
| 11167 | &ParsedAttrInfoSpeculativeLoadHardening::Instance, |
| 11168 | &ParsedAttrInfoStdCall::Instance, |
| 11169 | &ParsedAttrInfoStrictFP::Instance, |
| 11170 | &ParsedAttrInfoSuppress::Instance, |
| 11171 | &ParsedAttrInfoSwiftAsync::Instance, |
| 11172 | &ParsedAttrInfoSwiftAsyncName::Instance, |
| 11173 | &ParsedAttrInfoSwiftAttr::Instance, |
| 11174 | &ParsedAttrInfoSwiftBridge::Instance, |
| 11175 | &ParsedAttrInfoSwiftBridgedTypedef::Instance, |
| 11176 | &ParsedAttrInfoSwiftCall::Instance, |
| 11177 | &ParsedAttrInfoSwiftContext::Instance, |
| 11178 | &ParsedAttrInfoSwiftError::Instance, |
| 11179 | &ParsedAttrInfoSwiftErrorResult::Instance, |
| 11180 | &ParsedAttrInfoSwiftIndirectResult::Instance, |
| 11181 | &ParsedAttrInfoSwiftName::Instance, |
| 11182 | &ParsedAttrInfoSwiftNewType::Instance, |
| 11183 | &ParsedAttrInfoSwiftObjCMembers::Instance, |
| 11184 | &ParsedAttrInfoSwiftPrivate::Instance, |
| 11185 | &ParsedAttrInfoSysVABI::Instance, |
| 11186 | &ParsedAttrInfoTLSModel::Instance, |
| 11187 | &ParsedAttrInfoTarget::Instance, |
| 11188 | &ParsedAttrInfoTestTypestate::Instance, |
| 11189 | &ParsedAttrInfoThisCall::Instance, |
| 11190 | &ParsedAttrInfoThread::Instance, |
| 11191 | &ParsedAttrInfoTransparentUnion::Instance, |
| 11192 | &ParsedAttrInfoTrivialABI::Instance, |
| 11193 | &ParsedAttrInfoTryAcquireCapability::Instance, |
| 11194 | &ParsedAttrInfoTypeNonNull::Instance, |
| 11195 | &ParsedAttrInfoTypeNullUnspecified::Instance, |
| 11196 | &ParsedAttrInfoTypeNullable::Instance, |
| 11197 | &ParsedAttrInfoTypeNullableResult::Instance, |
| 11198 | &ParsedAttrInfoTypeTagForDatatype::Instance, |
| 11199 | &ParsedAttrInfoTypeVisibility::Instance, |
| 11200 | &ParsedAttrInfoUPtr::Instance, |
| 11201 | &ParsedAttrInfoUnavailable::Instance, |
| 11202 | &ParsedAttrInfoUninitialized::Instance, |
| 11203 | &ParsedAttrInfoUnlikely::Instance, |
| 11204 | &ParsedAttrInfoUnused::Instance, |
| 11205 | &ParsedAttrInfoUseHandle::Instance, |
| 11206 | &ParsedAttrInfoUsed::Instance, |
| 11207 | &ParsedAttrInfoUuid::Instance, |
| 11208 | &ParsedAttrInfoVecReturn::Instance, |
| 11209 | &ParsedAttrInfoVecTypeHint::Instance, |
| 11210 | &ParsedAttrInfoVectorCall::Instance, |
| 11211 | &ParsedAttrInfoVectorSize::Instance, |
| 11212 | &ParsedAttrInfoVisibility::Instance, |
| 11213 | &ParsedAttrInfoWarnUnused::Instance, |
| 11214 | &ParsedAttrInfoWarnUnusedResult::Instance, |
| 11215 | &ParsedAttrInfoWeak::Instance, |
| 11216 | &ParsedAttrInfoWeakImport::Instance, |
| 11217 | &ParsedAttrInfoWeakRef::Instance, |
| 11218 | &ParsedAttrInfoWebAssemblyExportName::Instance, |
| 11219 | &ParsedAttrInfoWebAssemblyImportModule::Instance, |
| 11220 | &ParsedAttrInfoWebAssemblyImportName::Instance, |
| 11221 | &ParsedAttrInfoWorkGroupSizeHint::Instance, |
| 11222 | &ParsedAttrInfoX86ForceAlignArgPointer::Instance, |
| 11223 | &ParsedAttrInfoXRayInstrument::Instance, |
| 11224 | &ParsedAttrInfoXRayLogArgs::Instance, |
| 11225 | }; |
| 11226 | |
| 11227 | static bool checkAttributeMatchRuleAppliesTo(const Decl *D, attr::SubjectMatchRule rule) { |
| 11228 | switch (rule) { |
| 11229 | case attr::SubjectMatchRule_block: |
| 11230 | return isa<BlockDecl>(D); |
| 11231 | case attr::SubjectMatchRule_enum: |
| 11232 | return isa<EnumDecl>(D); |
| 11233 | case attr::SubjectMatchRule_enum_constant: |
| 11234 | return isa<EnumConstantDecl>(D); |
| 11235 | case attr::SubjectMatchRule_field: |
| 11236 | return isa<FieldDecl>(D); |
| 11237 | case attr::SubjectMatchRule_function: |
| 11238 | return isa<FunctionDecl>(D); |
| 11239 | case attr::SubjectMatchRule_function_is_member: |
| 11240 | return isa<CXXMethodDecl>(D); |
| 11241 | case attr::SubjectMatchRule_namespace: |
| 11242 | return isa<NamespaceDecl>(D); |
| 11243 | case attr::SubjectMatchRule_objc_category: |
| 11244 | return isa<ObjCCategoryDecl>(D); |
| 11245 | case attr::SubjectMatchRule_objc_implementation: |
| 11246 | return isa<ObjCImplDecl>(D); |
| 11247 | case attr::SubjectMatchRule_objc_interface: |
| 11248 | return isa<ObjCInterfaceDecl>(D); |
| 11249 | case attr::SubjectMatchRule_objc_method: |
| 11250 | return isa<ObjCMethodDecl>(D); |
| 11251 | case attr::SubjectMatchRule_objc_method_is_instance: |
| 11252 | return isObjCInstanceMethod(D); |
| 11253 | case attr::SubjectMatchRule_objc_property: |
| 11254 | return isa<ObjCPropertyDecl>(D); |
| 11255 | case attr::SubjectMatchRule_objc_protocol: |
| 11256 | return isa<ObjCProtocolDecl>(D); |
| 11257 | case attr::SubjectMatchRule_record: |
| 11258 | return isa<RecordDecl>(D) || isa<CXXRecordDecl>(D); |
| 11259 | case attr::SubjectMatchRule_record_not_is_union: |
| 11260 | return isStruct(D); |
| 11261 | case attr::SubjectMatchRule_hasType_abstract: |
| 11262 | assert(false && "Abstract matcher rule isn't allowed" ); |
| 11263 | return false; |
| 11264 | case attr::SubjectMatchRule_hasType_functionType: |
| 11265 | return isFunctionLike(D); |
| 11266 | case attr::SubjectMatchRule_type_alias: |
| 11267 | return isa<TypedefNameDecl>(D); |
| 11268 | case attr::SubjectMatchRule_variable: |
| 11269 | return isa<VarDecl>(D); |
| 11270 | case attr::SubjectMatchRule_variable_is_thread_local: |
| 11271 | return isTLSVar(D); |
| 11272 | case attr::SubjectMatchRule_variable_is_global: |
| 11273 | return isGlobalVar(D); |
| 11274 | case attr::SubjectMatchRule_variable_is_local: |
| 11275 | return isLocalVar(D); |
| 11276 | case attr::SubjectMatchRule_variable_is_parameter: |
| 11277 | return isa<ParmVarDecl>(D); |
| 11278 | case attr::SubjectMatchRule_variable_not_is_parameter: |
| 11279 | return isNonParmVar(D); |
| 11280 | } |
| 11281 | llvm_unreachable("Invalid match rule" ); |
| 11282 | return false; |
| 11283 | } |
| 11284 | |
| 11285 | |